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.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on PromQL & Recording Rules