What is a recording rule, and when would you use one? [Basic]
Answer
A recording rule precomputes and stores the result of a PromQL expression as a new time series. I use recording rules for expensive, frequently used, or standardized queries such as service:error_ratio:rate5m.
Technical explanation
Recording rules improve dashboard performance and make alert expressions simpler and more consistent.
They are evaluated on a schedule by Prometheus and stored like normal metrics.
Naming should be consistent and indicate level, metric, operation, and window.
Hands-on example
Example rule:
groups:
- name: service-slo
rules:
- record: service:http_error_ratio:rate5m
expr: sum(rate(http_requests_total{status=~'5..'}[5m])) by (service) / sum(rate(http_requests_total[5m])) by (service)
Then alerts and dashboards reuse service:http_error_ratio:rate5m.
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]