You should use rate() instead of irate(), and then if you are using grafana 
7.2 or later 
<https://grafana.com/docs/grafana/latest/datasources/prometheus/#using-__rate_interval>
:

* In your data source definition, set the scrape interval to 5 seconds
* Use rate(foo[$__rate_interval]) in your queries

However, it's slightly broken.  What you'll actually get is a correct 
foo[...] range at large zoom, but at small zoom it won't go any smaller 
than foo[20s], which means it smears together three time intervals (i.e. it 
shows the average rate over 15 seconds).

As a workaround, you can set the data source scrape interval to 2.5 seconds 
if it accepts fractions, or 3 seconds if it doesn't.
More details here: https://github.com/grafana/grafana/issues/32169

This is considered a "working as intended, we won't fix" by Grafana.

On Friday, 30 July 2021 at 03:45:25 UTC+1 [email protected] wrote:

> My exporter scrapes metrics every 5 seconds. I set the range-vector of the 
> query to 10 seconds, which is 2x of scrape interval, in order to catch 
> 'spikes and dips',
>
> The problem is Grafana automatically controls the resolution(step) of the 
> graph, and I'm losing some data points when I set a long time range.
>
> Trivial solution is using '$__interval' or '$__rate_interval' variable 
> instead of constant range vector.
>
> But if I use variable for range-vector, I will lose many data points when 
> I monitor a long time range graph. Because irate() considers only the last 
> two samples.
>
> Is it okay to use irate() in Grafana? Or is there any better solution?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/489d6e33-c921-4cb2-a0e3-6be4a417cf91n%40googlegroups.com.

Reply via email to