-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add source label to all exported metrics #15
Conversation
Having a source label is a more reliable way to run multiple instances to collect from multiple devices. This also allows more effective dashboards, which no longer rely on exporter configuration.
This change was inspired by the current dashboard which is relatively painful to use if the exporter address changes from time to time. This makes maintaining the exporter in Kubernetes slightly painful. I have an updated dashboard that I use, which replaces the instance filter with source filter. I've uploaded the JSON to gist https://gist.github.com/ressu/63a6af7cd241da035b86a17461cb0154 (the only changes are in variables and filters) |
Hi, thanks for the input. The suggested |
There are 2 issues at play here. Instance is not an identifier that determines the source of the information and the fact that instance can be dynamic. Let's start with the latter. Instance is just an internal field in prometheus that can be used to distinguish multiple collectors. The intent is to allow redundancy and better scalability. It's not intended as an identifier for the source of the information. Instance will tell us where the exporter was listening, but not where it was collecting from. What makes things worse is that instance can be dynamic, like it is when running the exporter in environments like Kubernetes. It would be possible to artificially force the instance to stay stable, but that's still just shifting the problem. The other problem is that the instance is not identifying the source of the data. Let's say we wanted to collect information from 2 devices into the same prometheus instance. Sure it would take a bit of setup, but there is no reason why that wouldn't work. Except that now one would need to figure out which instance maps to which device. By adding a source label, we are signalling which device is the source of the metrics. Generally there are 2 patterns how this is resolved, one is by the exporter labeling the metrics with the source and the other is via the scrape configuration. Latter solution is usually used when the target is provided in the same configuration. For example in the blackbox exporter the targets are provided in the scraper configuration and indeed the instance variable is being overwritten by the value of target. Since this exporter has a static configuration file, I opted for the additional label solution instead. |
|
Finally had some time to spend on this.. It turns out that the Python prometheus client library doesn't support multi-target probing, so there is no real way of getting around this limitation. Unless the architecture is changed drastically. So I gave up.. 😆 I think you still have a strong argument in rewriting the instance name instead. In fact I ended up refactoring my setup to simply overwrite the instance name. So I extracted the dashboard from this PR into #18 so we can close this one. |
Having a source label is a more reliable way to run multiple instances
to collect from multiple devices. This also allows more effective
dashboards, which no longer rely on exporter configuration.