Define Prometheus recording rules and alerting rules in a rule file

domain: prometheus.io · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Create a YAML rule file and reference it in prometheus.yml under 'rule_files:' with the file path or glob pattern
  2. Add recording rules under a named 'groups:' entry with 'rules:' items containing 'record:' (new metric name, must follow naming convention) and 'expr:' (PromQL expression)
  3. Add alerting rules in the same or a separate group with 'alert:' name, 'expr:' PromQL condition, 'for:' pending duration, and 'labels:'/'annotations:' for routing and message context
  4. Use 'promtool check rules <file>' to validate syntax and expression correctness before deploying
  5. Configure Alertmanager in prometheus.yml under 'alerting:' with the Alertmanager address, then reload Prometheus and verify alerts appear in the Prometheus UI /alerts page

Known gotchas

Related routes

Write Prometheus recording rules and alerting rules with for and keep_firing_for clauses
prometheus.io · 5 steps · unrated
Define an SLO with Sloth and generate Prometheus recording and alerting rules
grafana.com · 6 steps · unrated
Configure Prometheus Alertmanager routing tree with inhibition rules and receiver grouping to reduce alert noise during incidents
prometheus.io · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans