Create the configuration for a dedicated metrics publishing service#6726
Create the configuration for a dedicated metrics publishing service#6726TheOneFromNorway wants to merge 2 commits intonextfrom
Conversation
- This allows for publishing service-independent metrics - This is valuable for higher level stats that should not be produced per running container
| #!/usr/bin/env ruby | ||
| # frozen_string_literal: true | ||
|
|
||
| require_relative "../config/environment" |
There was a problem hiding this comment.
Do we actually need to load the entire Rails env? Or is this just to load bundler so we can require prometheus_exporter/instrumentation? Just looking at PrometheusExporter::CustomActiveRecordCollector it's not clear to me that all of Rails is needed.
| labels = { | ||
| "TaskId" => resolve_label("PROMETHEUS_TASK_ID_LABEL") do | ||
| ARGV.include?("skip-server-labels") ? nil : fetch_ecs_task_id | ||
| end, | ||
| "ServiceName" => resolve_label("PROMETHEUS_SERVICE_NAME_LABEL") do | ||
| ARGV.include?("skip-server-labels") ? nil : ENV["SERVICE_NAME"] | ||
| end | ||
| }.compact |
There was a problem hiding this comment.
I think I would've expected skip-server-labels to override the env vars? For example, I would expect that a shell could have those env vars set from previous testing / work, but if you ran this script with skip-server-labels it wouldn't send those. I think the way resolve_label works is that it'll ignore this block, and the ARGV check inside it, if the env var is set.
If I'm right, simply swapping the ARGV check with the fetch_ecs_task_id call would fix it, although this syntax might be invalid because of the block, probably will have to tweak it.
| labels = { | |
| "TaskId" => resolve_label("PROMETHEUS_TASK_ID_LABEL") do | |
| ARGV.include?("skip-server-labels") ? nil : fetch_ecs_task_id | |
| end, | |
| "ServiceName" => resolve_label("PROMETHEUS_SERVICE_NAME_LABEL") do | |
| ARGV.include?("skip-server-labels") ? nil : ENV["SERVICE_NAME"] | |
| end | |
| }.compact | |
| labels = { | |
| "TaskId" => ARGV.include?("skip-server-labels") ? nil : resolve_label("PROMETHEUS_TASK_ID_LABEL") do | |
| fetch_ecs_task_id | |
| end, | |
| "ServiceName" => ARGV.include?("skip-server-labels") ? nil : resolve_label("PROMETHEUS_SERVICE_NAME_LABEL") do | |
| ENV["SERVICE_NAME"] | |
| end | |
| }.compact |
- As it relies on the same template infrastructure the modifications are trivial
06b8434 to
891c1a8
Compare
...
Jira Issue - MAV-XXX
Screenshots
...