what is the default grafana setting for $__rate_interval
Asked Answered
G

1

8

I understand that rate(xyz[5m]) * 60 is the rate of xyz per minute, averaged over 5 mins.

  1. How then would $__rate_interval and $__interval be defined, possibly in the same syntax?
  2. What format is rate being measured here, in my panel? Per minute, per second?
  3. What is the interval= 30s in my panel here? My scraping interval is set to 5s.my dash board
  4. How do i change the rate format?
Gow answered 25/5, 2022 at 5:24 Comment(0)
S
18
  1. See New in Grafana 7.2: $__rate_interval for Prometheus rate queries that just work.
  2. Rate is always per second. See Prometheus documentation for the rate function.
  3. Click on Query options, then click on the Info-Symbol. An explanation will be displayed.
  4. To get rate per minute, just multiply the rate with 60.

Edit: ($__rate_interval and $__interval)

Prometheus periodically fetches data from your application. Grafana periodically fetches Data from Prometheus. Grafana does not know, how often Prometheus polls your application for data. Grafana will estimate this time by looking at the configuration and assuming that every scrape gives us one data point. The $__interval variable then expands to the duration between two data points in the graph (Note that this is only true for small time ranges and high resolution as the intended use case for $__interval is reducing the number of data points when the time range is wide. See Approximate Calculation of $__interval.)

If the time-distance between every two data points in each series is 15 seconds, it does not make sense to use anything less than [15s] as interval in the rate function. The rate function works best with at least 4 data points. Therefore [1m] would be much better than anything betweeen [15s] and [1m]. This is what $__rate_interval tries to achieve: guessing a minimal sensible interval for the rate function.

Personally, I think, this does not always work if your application delivers sparse data (less than one data point per scrape). I prefer using fixed intervals like 10m or even 1h or 1d in these situations. The interval need to be great enough to get you enough data points for the metric to work with the rate function.

A different approach would be to use any of $__rate_interval and $__interval but also set the Min step parameter for the query in the Grafana UI to be big enough.

Scalariform answered 25/5, 2022 at 8:9 Comment(1)
Went through the documentation, but still have difficulty understanding $__rate_interval and $_interval. An explanation in laymen terms would be very appreciated.Gow

© 2022 - 2024 — McMap. All rights reserved.