Why must you use rate() on counters instead of the raw value?
⚡
Quick Answer
Counters are monotonic and reset on restart; rate() computes the per-second increase and handles resets.
Detailed Answer
A raw counter is a meaningless ever-growing number and drops to zero on process restart. rate(counter[5m]) gives the average per-second increase over the window and correctly accounts for resets. Use rate for graphs/alerts; irate only for fast-moving graphs.
Code Example
sum by (service) (rate(http_requests_total[5m]))
💡
Interview Tip
rate handles counter resets — a key correctness point.
prometheusratecounters