Explain `rate()`.
BeginnerConceptPromQL & Recording Rules
Answer
rate(counter[5m]) returns the per-second average increase of a counter over the last 5 minutes, handling counter resets and extrapolating to the window edges.
sum by (job) (rate(http_requests_total[5m]))
Rules: only apply it to counters, apply rate first and sum after, and make the range at least 4 times the scrape interval so there are enough samples.
More on PromQL & Recording Rules
What are the PromQL data types?BeginnerWhat label matchers does PromQL support?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?IntermediateHow do PromQL aggregation operators and `by`/`without` work?Beginner