Reputation: 23
I have done a lot of analysis on rate() function but have not got a perfect answer for the same. Lets Suppose I have set the scraping level as 1m and this is my expression rate(http_request_total[5m])
My question is this how rate will get calculated(my understanding is correct)? and how the extrapolation will be done the rate() in this example? I know for increase() its like the value we get from the above multiplied to the total interval
Upvotes: 1
Views: 2552
Reputation: 819
My question is this how rate will get calculated(my understanding is correct)?
Theoretically, it is correct (except in your example you have 6 datapoints, not 5). But the "magic" starts happening when you add start
and end
params to your query. In most cases, these two params will not exactly match t1
and t5
from your example, and Prometheus won't be able to capture one or more data points of yours:
In the example above, time window isn't perfectly aligned with real values. In this case, value of v1 will be missed, which would affect the result since increase will be calculated between v5 and v2. Knowing the avg interval between received values, Prometheus could assume that it didn't capture some of the values. So it will try to extrapolate the result by simply multiplying it by coefficient.
I'd recommend reading this great thread https://github.com/prometheus/prometheus/issues/3746.
I'd also recommend reading how alternative rate
could work here https://medium.com/@romanhavronenko/victoriametrics-promql-compliance-d4318203f51e in "Better rate" section. Disclosure, I am one of the developers at VictoriaMetrics, so take it with a grain of salt.
Upvotes: 1