How does the rate() function work, and why use it on counters? [Basic]
Answer
rate() calculates the per-second average increase of a counter over a range window and accounts for counter resets. It should be used on counters because raw counters only show lifetime totals and are not useful for current traffic or error rate.
Technical explanation
Counters reset when a process restarts, and rate() handles that reset logic.
The range should be several scrape intervals long; for a 30-second scrape interval, 5 minutes is a common starting point.
Use increase() when you want the total increase over the window rather than a per-second rate.
Hands-on example
Example: requests per second = sum(rate(http_requests_total[5m])) by (service). Five-minute error percentage = 100 * sum(rate(http_requests_total{status=~'5..'}[5m])) / sum(rate(http_requests_total[5m])).
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Observability interview questions
- What is observability, and how is it different from traditional monitoring? [Basic]
- What are the three pillars of observability (metrics, logs, traces)? [Basic]
- What is the difference between monitoring and observability in practice? [Basic]
- What are the four golden signals of monitoring? [Basic]
- What is the difference between the USE method and the RED method? [Basic]
- When would you use the USE method versus the RED method? [Basic]
- What is an SLI, an SLO, and an SLA, and how do they relate? [Basic]
- How do you choose good SLIs for a service? [Basic]