Rules for Prometheus and Grafanas
Rules in Prometheus are expressions evaluated at a regular interval and defined in rule files. Recording rules precompute expensive PromQL results into new series, and alerting rules fire when a condition holds for a set duration, with labels and annotations describing the alert.
Stage: Alerting · Part of the Prometheus and Grafana roadmap · Last reviewed 19 November 2026
What to learn in Rules
- Write a recording rule that stores a pre-aggregated rate
- Define an alerting rule with expr, for, labels and annotations
- Choose a for duration that avoids flapping alerts
- Validate rule files with promtool check rules
- Alert on symptoms such as error rate instead of causes
Rules interview questions
What is the purpose of the for clause in an alerting rule?
The for clause requires the condition to stay true for a given time before the alert moves from pending to firing. It filters out brief spikes and reduces noisy notifications, at the cost of slightly slower detection.
When should you use a recording rule?
Use one when a query is expensive or reused often, such as dashboards or alerts over large aggregates. The rule evaluates it once per interval and stores the result as a new series, which speeds up reads.
Where Rules fits in the Prometheus and Grafana roadmap
Rules belongs to the Alerting stage (intermediate level). Know when to act.
Other units in this stage
Back to the full Prometheus and Grafana roadmap