Hi,
I intend to submit a PR to modify the Prometheus extension. Creating this post to track progress.
Currently the LibreNMS Prometheus extension will write metrics via Prometheus PushGateway with label names based on the source data in LibreNMS. For instance it will write metrics with labels like this for data sourced from the SNMP IF-MIB:
OUTUCASTPKTS
ifOutUcastPkts_rate
INOCTETS
ifInErrors_rate
This is fine and the metric export works as expected. The Prometheus guidelines for metric names, however, state that they “should have a (single-word) application prefix relevant to the domain the metric belongs to”: Metric and label naming | Prometheus
Currently the LibreNMS Prometheus extension does not confirm to this guideline. This leads to a less-than-ideal result in our environment. We have data from many different sources in our Prometheus database, and the source of every metric is easily identifiable from the metric names. For instance:
atlas_ping_avg_latency
bird_protocol_prefix_filter_count
exim_smtp_errors_total
nginx_vts_server_requests_total
squid_server_all_errors_total
Ideally the metrics exported from LibeNMS would have a similar prefix on them (‘librenms’ for instance), to aid grouping and discovery. It would also prevent any potential namespace collision with other data sources which might omit to use an source-specific prefix.
To give a practical example, it would be useful if the example metrics I gave were instead written to Prometheus like this:
librenms_OUTUCASTPKTS
librenms_ifOutUcastPkts_rate
librenms_INOCTETS
librenms_ifInErrors_rate
My proposal would be to add another configurable option to add a prefix if so desired:
$config['prometheus']['prefix'] = 'librenms'; # Optional
This should be optional, and default to an empty string if not specified. Which should ensure backwards-compatibility.
I welcome and comments or feedback, I am currently prepping my git environment and will submit the PR as soon as that is ready.
thanks,
Cathal.