Skip to content

Add name & server labels and support multiple UPSes - #6

Open
minus7 wants to merge 2 commits into
DRuggeri:masterfrom
minus7:name-labels
Open

Add name & server labels and support multiple UPSes#6
minus7 wants to merge 2 commits into
DRuggeri:masterfrom
minus7:name-labels

Conversation

@minus7

@minus7 minus7 commented Jan 16, 2021

Copy link
Copy Markdown

The NUT server already has names for the UPSes, so just using those seems like a straight forward solution with less potential to accidentally mislabel UPSes. Adding them allows nut_exporter to export multiple UPSes at once (though I did not test that yet since I don't have two UPSes connected to the same machine right now).

This is a kind of bigger change in the way the user interfaces with nut_exporter, though it should not break any existing setups.

This avoids having to manually add labels in the scraper per instance.
Since each metric has the UPS name as label, this is not a problem
anymore.
@DRuggeri

Copy link
Copy Markdown
Owner

Thanks, @minus7 - I tend to agree, but the Prometheus project had the opinion that the Prometheus server must be responsible for service discovery rather than the exporter. The initial version of this exporter supported exactly what you're describing: Just iterate through all the UPS devices and export all the data.

You can read more here:
prometheus/docs#1749 (comment)

While thinking about this, perhaps another solution could be to add a simple endpoint to this exporter that returns the list of UPS devices known to the NUT daemon - and then wrap that information with a shell script or something on the Prometheus side that writes a file_sd_config. That feels overly complicated for a simple thing, IMO... but what do you think?

@minus7

minus7 commented Jan 30, 2021

Copy link
Copy Markdown
Author

Thanks, @minus7 - I tend to agree, but the Prometheus project had the opinion that the Prometheus server must be responsible for service discovery rather than the exporter. The initial version of this exporter supported exactly what you're describing: Just iterate through all the UPS devices and export all the data.

You can read more here:
prometheus/docs#1749 (comment)

That's understandable for the server label, but not for the name label. Scraping all UPSes off one NUT server is similar to what e.g. the node exporter does with regard to disks. Just like disks, the UPSes do have names on the NUT server already, even if it's just one UPS. It seems odd to me not to use the existing name(s).

While thinking about this, perhaps another solution could be to add a simple endpoint to this exporter that returns the list of UPS devices known to the NUT daemon - and then wrap that information with a shell script or something on the Prometheus side that writes a file_sd_config. That feels overly complicated for a simple thing, IMO... but what do you think?

Yeah, I agree, that's not too helpful; it's easy enough to write the config by hand after all. From a practical point of view, simply scraping all UPSes on a NUT server by default is just easier and more straight forward to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants