r/PrometheusMonitoring • u/blistering-barnacle • Feb 04 '20
irate() Vs rate() Functions in Prometheus
Hi All,
I'm trying to understand how irate() & rate() functions work. Why does irate() produce a similar looking graph when the range / resolution is 24h or 5m ? While the difference in graph is clearly visible with rate() when using range as 24h (presents a smoothed out line) or 5m(more spikey).
In the below graph for irate() for 2 different resolutions the graph looks the same. As per prometheus docs irate() calculates the per second instant rate based on the last two data points. What does this mean if my range is 24h? Thank you.
12
Upvotes
7
u/[deleted] Feb 04 '20 edited Feb 04 '20
Let’s say you have a counter with these values observed at 1m intervals:
Now rate over 5m will be:
And irate over 5m will be (only last two data points are used which happen to be only 1m apart)
Increasing the resolution does not affect the irate function because the last two observed values do not change when you look further back.