What is `$__rate_interval` in Grafana and why use it over a fixed `[5m]`?
IntermediateConceptPromQL & Recording Rules
Answer
$__rate_interval is a Grafana variable equal to max($__interval + scrape interval, 4 x scrape interval). It guarantees that the range in rate() always contains enough samples, no matter how far you zoom out, and avoids gaps at small ranges.
sum(rate(http_requests_total[$__rate_interval]))
Set the datasource's "Scrape interval" correctly for it to work.
More on PromQL & Recording Rules
What are the PromQL data types?BeginnerWhat label matchers does PromQL support?BeginnerExplain `rate()`.Beginner`rate()` vs `irate()`: what is the difference?IntermediateWhat does `increase()` return and why is it sometimes a non-integer?IntermediateWhy must you `rate()` before `sum()`, never the reverse?Intermediate