Reputation: 3405
Is there a way to make a Prometheus counter in Grafana truly monotonic?
The counters on my server (using the Prometheus Java library) get reset whenever the server is restarted and the counter drops to zero in Grafana too. I cannot find a way in the documentation for Prometheus queries. Neither does the Java library provide a way to make a Counter persistent over restarts.
Upvotes: 7
Views: 3623
Reputation: 743
With counters, you almost never care about the value itself, but only about its rate of increase. Thus, counters are always meant to be used in combination with the rate()
or increase()
functions. These functions handle counter resets for you (any non-monotonic increase will be treated as a counter reset and neutralized in the rate calculation).
Upvotes: 7
Reputation: 34112
The way to approach this is to use the rate
function, which handles counter resets.
Upvotes: 1