nut_exporter
nut_exporter copied to clipboard
Add name & server labels and support multiple UPSes
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.
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: https://github.com/prometheus/docs/pull/1749#issuecomment-699855645
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?
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.