Why must you `rate()` before `sum()`, never the reverse?
IntermediateConceptPromQL & Recording Rules
Answer
rate() detects counter resets per series. If you sum first, one pod restarting (its counter dropping to 0) makes the summed value drop, and rate interprets that as a reset of the whole sum, producing a huge false spike.
sum(rate(http_requests_total[5m])) # correct
rate(sum(http_requests_total)[5m:]) # wrong, breaks on restarts
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?IntermediateHow do PromQL aggregation operators and `by`/`without` work?Beginner