2 fixes in modules/kubernetes/annotations/metrics.alloy
In one of the first steps, __tmp_scrape is default set to false, but the next step watches for metrics.grafana.com/scrape to be blank or true and then makes the value of __tmp_scrape = true. So __tmp_scrape would never be blank. But the step that runs if the attribute scrape_port_named_metrics = true only runs if __tmp_scrape is true or blank. The point of that attribute is to scrape any port that contains the word metrics in its name, regardless of the metrics.grafana.com/scrape attribute, but it was not working that way since it could never be blank. We only want that step to not run if metrics.grafana.com/scrape = false, which it is now only set to __tmp_scrape if the attribute is set to false, not just by default.
The step that watches for metrics.grafana.com/port to be set to override the __address__ port had an additional source label added to it when it was copied from grafana-agent-modules, but the regex was not adjusted to account for the additional label, so the step would never work.
2 fixes in modules/kubernetes/annotations/metrics.alloy
__tmp_scrape
is default set tofalse
, but the next step watches formetrics.grafana.com/scrape
to be blank ortrue
and then makes the value of__tmp_scrape
=true
. So__tmp_scrape
would never be blank. But the step that runs if the attributescrape_port_named_metrics
=true
only runs if__tmp_scrape
is true or blank. The point of that attribute is to scrape any port that contains the wordmetrics
in its name, regardless of themetrics.grafana.com/scrape
attribute, but it was not working that way since it could never be blank. We only want that step to not run ifmetrics.grafana.com/scrape
=false
, which it is now only set to__tmp_scrape
if the attribute is set to false, not just by default.metrics.grafana.com/port
to be set to override the__address__
port had an additional source label added to it when it was copied from grafana-agent-modules, but the regex was not adjusted to account for the additional label, so the step would never work.