I use the folowing metrics :
but i did not found in the documentation the exact calculation done by this rate function.
Il mathematics I understand rate as dervative.
But question is what is the interval used? is ther many point inside this interval ?
Is there parameter to control it more?
For exemple If I want to calculate the “n value” - “n-1 value” / interval ?
how can i do that ?
The $rate_interval is defined as:
$__rate_interval variable is meant to be used in the rate function. It is defined as max(
$__interval + Scrape interval , 4 * Scrape interval ), where Scrape interval is the Min step setting (AKA query interval, a setting per PromQL query), if any is set, and otherwise the _Scrape interval as set in the Prometheus data source (but ignoring any Min interval setting in the panel, because the latter is modified by the resolution setting).
There’s a really great blog written when the $rate_interval feature was released that helps with some examples of the problems it solves and how it works:
Thanks for reply.
Indeed I found a lot of information on the difference between $__rate_interval and $_interval.
Initialy I was using $_interval with some trouble when selecting a short interval.
But my question is more on the rate function itself.
I need to calculate the Delta between 2 mesurment,and I have the feeling that rate function is more complex than taht?
maybe there are another way to get the delta divided by the interval of theses 2 points?
Depending on your use case, you could also consider
increase(not adjusted per second like rate), all of the functions and what they do are explained in the prometheus query functions docs:
Thanks for the link but there is something I did not understand…
I have a kWh value that I monitor.
When I plot a graph in grafana with this query in a time series :
in the last 7 days I pass from 690 kWh to 694kWh
When I try to display a “stat” with the following query (with a selected 7 days periodes) :
I get 4 kWh which seem’s Ok
but if I try this query instead :
I get 7MWh ???
I think there is something I do not understand…
Any idea of what?
Do you really have the $ in your 7d interval?
Sorry a typo here but not in graphana
With [7d] I have 7MWh…
(I have corrected the above post)