Closed rynbrd closed 7 years ago
Hi @BlueDragonX, thanks for the PR. Unfortunately, I think it goes against the exporter guidelines.
The tl;dr is they recommend setting these kinds of labels on the Prometheus side when setting up scrape targets. Depending on how you set up your scrapes you could use job names, job labels, or relabeling to do this.
Personally I use Kubernetes to auto-discover my exporters, and use relabeling to set a target label based on a label on the exporter pod, which identifies the cluster the pod is monitoring.
Is there anything about your situation that means you can't use target labeling?
We're using ECS with Consul for service discovery. I suppose I could set a tag on the service in Consul and add a relabel rule in the Prometheus consul_sd section. I'm not convinced this is better, though. It requires modifying both my container deployment and Prometheus configuration. This PR allows me to do so in only one place.
The rewrite rule I'm using is generic - it applies to any pod I want to scrape, and the label it uses applies to all my kubernetes pods, so nothing is specific this particular exporter for me.
Being able to support this at a platform level, rather than requiring the exporters I use(/maintain) to support it, is a big benefit for me.
I'm going to stick with the guidelines, for now at least. I hope you're able to find a solution that works for you (even if it's using a fork!).
This adds an
-l
flag that allows you to add labels to the exported metrics.Our use case is running multiple Kafka clusters monitored by the same Prometheus instance. We would like to label the metrics with the name of the cluster they belong.