Interview Prep/Monitoring & Observability/Prometheus and PromQL at Scale

When should you create recording rules, and how do you name them?

IntermediateScenarioPrometheus and PromQL at Scale
Answer

Situation read → Expensive or frequently reused queries slow dashboards and alert evaluation.

What I'd do →

  1. Create recording rules for aggregations used by dashboards or alerts, especially histogram_quantile and cross-label sums over many series.
  2. Use the convention level:metric:operations:
groups:
  - name: api.rules
    interval: 30s
    rules:
      - record: job:http_requests:rate5m
        expr: sum by (job) (rate(http_requests_total[5m]))
  1. Keep labels the aggregation preserves in the level part. The name should say what was aggregated.
  2. Do not record everything. Each rule adds series and evaluation cost.

Why → Pre-computation trades small storage for fast, consistent queries.

Interview tip → Alerts should use recording rules for SLI expressions, so dashboards and alerts agree.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Prometheus and PromQL at Scale