Work with Prometheus to stop globally registering metrics
While building out dashboards for Grafana Agent Flow, we noticed that a few sets of metrics are globally registered to prometheus.DefaultRegistry:
-
prometheus_target_*metrics -
prometheus_sd_*metrics
Globally registering them is fine for Prometheus where there's only one scrape manager or SD manager, but it's an issue for Flow where there may be multiple at runtime with different IDs.
We should work with upstream to stop globally registering these metrics so we have tighter control over them.
I raised an issue on the Prometheus repo regarding this.
I opened a draft PR for this as well.
I updated Prometheus' main branch with all the changes which I believe are necessary. I'm currently waiting for Prometheus 2.50 to be released, so that I can update the Agent with it.
2.50 has been released, so I'm going to close this specific issue in favor of updating our Prometheus dependency.