Conversation
daemon/metrics.c and daemon/metrics.h for statistics in prometheus metrics.
…ics-port, and metrics-path options.
…e disabled there is no http service created.
add documentation in man page, and in the example config file.
It sounds a bit odd to me that a server would expose Prometheus metrics but there would be a configuration option that resets the metrics (or not). That would be a weird thing to do in the Prometheus ecosystem, e.g. sometimes you have multiple metrics scrapers running simultaneously for a high availability setup, or you hit the /metrics endpoint manually with curl at the same time that a scraper is running. So you don't want to reset the metrics after a fetch because that would be inherently racy. Looking at the source in this PR it looks like every metric is a gauge, except for
So metrics that count the number of events that occur, like DNS queries, should be counters, and metrics that count the size of data structures that can increase or decrease in size like the number of request list entries, should be gauges. There should not be an option to reset metrics to zero, and metrics that should be defined as counters should not be defined as gauges instead in order to support resetting them to zero. I am not quite sure what you mean by "It can also work with cumulative enabled, but the graphs would go up." For something like a DNS server or an HTTP server that is counting the number of requests it has processed, you would typically want the server's Prometheus metrics endpoint to expose the total (i.e. cumulative) number of requests it has processed since startup, as a counter (and these counter values would necessarily increase monotonically over time), and then you would use a Prometheus function like rate or irate to calculate per-second rates based on that metric. |
|
Thank you for looking at the statistics set up. Currently it is the same as the contrib/metrics.awk set up. But of course, with |
|
Looking at So
Yes, I suppose if the Probably the safest thing to do would be to have the HTTP
That would probably be very confusing. |
…f query metrics, and do not reset the stats. There is a warning when statistics-cumulative has the wrong value. But the stats are not reset from the metrics endpoint regardless. The contrib/metrics.awk script is also updated, and the documentation recommends the cumulative setting.
|
Changed it, it does not reset the stats when queried with the metrics interface. And documentation suggests cumulative stats. Also fixed the contrib version. The metrics are set to be of type |
This change adds prometheus metrics support.
It is enabled with
metrics-enable: yesin the unbound.conf config file. It can have settings withmetrics-interface: 127.0.0.1andmetrics-port: 9100andmetrics-path: "/metrics".The settings
statistics-cumulative: noandextended-statistics: yes, can make more out of the metrics printout. It can also work with cumulative enabled, but the graphs would go up. It prints the same output style as thecontrib/metrics.awkscript does. It prints more values.There is also an added unit test, that checks if the output works. The metrics support needs libevent 2 or later. The sockets for serving it put on the same event base as that the remote control uses, it is the event base of the first worker.
Fixes #352 (feature request for prometheus metrics support).