We graph fast counters with sum(rate(my_counter_total[1m]))
or with sum(irate(my_counter_total[20s]))
. Where the second one is preferrable if you can always expect changes within the last couple of seconds.
But how do you graph slow counters where you only have some increments every couple of minutes or even hours? Having values like 0.0013232/s is not very human friendly.
Let's say I want to graph how many users sign up to our service (we expect a couple of signups per hour). What's a reasonable query?
We currently use the following to graph that in grafana:
- Query:
3600 * sum(rate(signup_total[1h]))
- Step: 3600s
- Resolution: 1/1
Is this reasonable?
I'm still trying to understand how all those parameters play together to draw a graph. Can someone explain how the range selector ([10m]
), the rate()
and the irate()
functions, the Step
and Resolution
settings in grafana influence each other?
3600 * sum(rate(signup_total[1h]))
is the same assum(increase(signup_total[1h]))
– Edholmincrease()
function in Prometheus can return unexpected fractional results for slowly changing integer counters such as the number of signups or the number of pageviews. This is due to extrapolation for rate() and increase(). If you need the correct results, then tryincrease()
function from MetricsQL. – Bracy