Two systems, one clean handoff. Prometheus evaluates rules and decides what's true. Alertmanager catches firing alerts and decides who hears about them.

needsmake up obs

Orientation

competency 4.1 · alerting and notification routing

Most "where do I configure X?" questions are really asking which side of the handoff owns X. Thresholds, for durations, and labels live in Prometheus. Grouping, routing, silences, inhibition, mute intervals, and receivers live in Alertmanager. Nail that boundary and the rest is straightforward YAML.

Prometheus                                       Alertmanager
   rule groups, evaluated every 30s              receives firing alerts via HTTP
   expr → Inactive → Pending (for:) → Firing ──▶ route → group → inhibit → silence → receiver
   labels decide routing                         group_wait / group_interval / repeat_interval
   annotations describe                          webhook · email · Slack · PagerDuty

Rules

PrometheusRule · states · recording rules

A PrometheusRule CRD bundles groups of alerting and recording rules. Each alerting rule pairs a PromQL expression with four key fields:

  • for: how long the expression must stay true before Pending promotes to Firing. It's your flap filter: too short wakes people on brief blips, too long lets outages drag on.
  • labels: routing keys like severity, team, and service. Whatever Alertmanager routes match on has to be attached here.
  • annotations: human context like summary, description, and runbook_url, templated with {{ $labels.x }} and {{ $value }}.
  • keep_firing_for: the mirror image of for; holds an alert in Firing briefly after the expression clears so flapping symptoms don't spam resolved/firing pairs.

Recording rules live in the same CRD and precompute heavy queries into fast series on a schedule (following the level:metric:operation convention, like job:http_errors:rate5m). Whenever a scenario says "this Grafana dashboard takes 30 seconds to render," a recording rule is the answer.

Same silent selector trap as ServiceMonitors

Prometheus only loads PrometheusRule objects that match its ruleSelector. Our lab uses {} (pick up everything), while a stock Helm install demands the release label. An unmatched rule silently never evaluates with zero errors. Always check the selector before blaming your PromQL.

Alert states, and where each shows up

Alerts move from Inactive → Pending (expression true, waiting out for) → Firing. Pending alerts appear in Prometheus's Alerts UI and nowhere else; Alertmanager hasn't even heard about them yet. Add evaluation interval + for + group_wait to know how long an alert takes to land; on a stock stack, 2–3 minutes is completely normal.

Trace the timing yourself before concluding your alerting pipeline is broken:

What separates good alerts from pager noise

  • Page on symptoms, not causes. Alert on user-facing pain (error rate, latency, downtime) instead of every internal wobble. Cause-based alerts multiply endlessly; symptom alerts stay focused.
  • Make every page actionable. If nobody is getting out of bed to fix it at 3am, turn it into a dashboard panel or a ticket, not a page.
  • Alert on SLO burn rate when possible. Pairing a short window and a long window ("multi-window multi-burn-rate") pages based on how fast you're burning error budget rather than arbitrary static thresholds.
  • Link a runbook. Adding runbook_url to annotations is the highest-leverage on-call upgrade you can make.

Routing

tree · grouping · silence · inhibition

Watch the pipeline order: routing runs first. Alertmanager walks the route tree to pick the matching route, which determines group_by and timers; only after that do inhibition, silences, wait timers, and deduplication run before hitting the receiver. Mixing up that order leads to false assumptions like expecting a silence to prevent alerts from grouping.

Alertmanager organizes routes as a tree. Alerts enter at the root and follow the first matching child branch (set continue: true if an alert should also match sibling branches). Each route sets its receiver and timing knobs:

SettingMeansTypical
group_bybatch alerts sharing these labels into one notification[alertname, namespace]
group_waitpause before the first send so sibling alerts arrive together30s
group_intervalwait time before sending new alerts added to an active group5m
repeat_intervalhow often to re-notify while a group stays unresolved4h–12h
matchersconditions selecting which alerts take this branchseverity="critical"

Silences temporarily mute matching notifications (created via UI or amtool) without touching config (note that Prometheus still shows the alert firing, because silences mute notifications, never truth). Inhibition suppresses lower-priority downstream alerts automatically whenever a bigger related alert is firing (like a node outage silencing pod alerts on that node), wired via source_matchers, target_matchers, and equal labels. Know the crisp distinction: silences are temporary and human-driven; inhibitions are permanent, relationship-based rules.

Always inspect the rendered config

The operator compiles your config and any selected namespaced AlertmanagerConfig CRDs into a single generated Secret, and Alertmanager's Status page shows the exact live YAML. Always verify your route landed in that rendered config rather than stopping at kubectl apply.

One special alert you'll spot immediately: Watchdog, which fires 24/7 on purpose. It's a dead-man's switch: an external service listens for its heartbeat and pages you if it stops arriving, proving Prometheus and Alertmanager themselves are still alive.

Alertmanager config, field by field

matchers, time intervals, inhibition, AlertmanagerConfig scoping

Route fields

  • matchers: list of Prometheus-style selector strings like severity="critical", team=~"platform|sre", or namespace!="" (legacy match/match_re still parse, though deprecated). Watch out for a child route with no matchers: it matches everything and silently swallows alerts meant for later siblings.
  • continue (default false): lets an alert keep evaluating sibling routes after matching. The root route has no matchers and serves as your catch-all receiver.
  • group_by: inherits from its parent unless overridden; set ['...'] to turn off grouping completely (one notification per alert). Defaults: group_wait: 30s, group_interval: 5m, repeat_interval: 4h (keep repeat_interval a multiple of group_interval).
  • receiver: points to an entry in receivers[] containing one or more integration blocks (webhook_configs, slack_configs, pagerduty_configs, email_configs, opsgenie_configs, msteams_configs). Set send_resolved: true to receive recovery notices.

Scheduled muting with time intervals

Define named schedules under top-level time_intervals (replacing the deprecated mute_time_intervals key), specifying times (start_time/end_time in HH:MM, end exclusive, 24:00 allowed), weekdays (['monday:friday']), days_of_month (['1:7', '-1']), months, years, and an IANA location (defaults to UTC). Attach them to any route with mute_time_intervals: [weekends] (quiet during the window) or active_time_intervals: [business_hours] (quiet outside the window; if both are present, mute wins). Muted alerts still fire in Prometheus and appear active in Alertmanager; only notifications wait until the window lifts.

Inhibition and silences in practice

  • Each inhibit_rules[] item specifies source_matchers (the bigger alarm), target_matchers (the noise to suppress), and equal (labels that must match between both). Subtlety: missing and empty labels count as equal, so equal: [namespace] lets a cluster-wide alert without a namespace label inhibit other alerts that also lack namespace. An alert never inhibits itself.
  • Silences carry matchers, start/end times, and a comment (created via UI, amtool silence add alertname=X --duration 2h --comment ..., or POST /api/v2/silences). They live in Alertmanager's local state rather than config YAML, so without a PVC they vanish on restart. Test route trees offline with amtool config routes test --config.file am.yml severity=critical team=db and validate syntax with amtool check-config.

Operator-managed Alertmanager configs

You can drive Alertmanager three ways: spec.configSecret (a raw config Secret), spec.alertmanagerConfiguration (a single global AlertmanagerConfig in Alertmanager's namespace), or namespaced AlertmanagerConfig CRDs picked up via alertmanagerConfigSelector and alertmanagerConfigNamespaceSelector. For multi-tenant safety, the operator automatically injects namespace="<its namespace>" into every route and inhibition rule from a merged namespaced AlertmanagerConfig, which is why a tenant config can't catch cluster-wide alerts that lack a namespace label. Also note the casing flip: CRD fields are camelCase (groupBy, groupWait, repeatInterval), while the generated Secret (alertmanager-<name>-generated) renders snake_case.

Check the handoff pointer

If Prometheus shows alerts firing while Alertmanager stays completely empty (and no silence or route explains it), check spec.alerting.alertmanagers[] on the Prometheus CR: a wrong Service name or renamed port silently drops the handoff. Verify discovery under Status → Runtime & Build Information → Alertmanagers in Prometheus.

SLO burn-rate alerts and unit-testing rules

the multi-window table, alert hygiene, promtool test rules

A 99.9% 30-day SLO gives you a 0.1% error budget (~43 minutes of full downtime per month). Burn rate measures how fast you're spending it: a burn rate of 1 consumes 100% of the budget in exactly 30 days. The SRE Workbook pairs a long window (confirms the burn is real) with a short window 1/12th as long (stops paging immediately once recovery lands):

Burn rateLong windowShort windowBudget spent at triggerAction
14.41h5m2% of the monthpage
66h30m5%page
31d2h10%ticket
13d6h10%ticket

For a 99.9% SLO, the 1h rule reads error_ratio_1h > 14.4 * 0.001 and error_ratio_5m > 14.4 * 0.001, backed by recording rules like slo:sli_error:ratio_rate1h computing sum(rate(http_requests_total{code=~"5.."}[1h])) / sum(rate(http_requests_total[1h])). Precomputing those ratios keeps evaluation fast and alert definitions clean.

Alert hygiene that stands out

  • Stick to one clean severity taxonomy (critical pages, warning tickets, info dashboards), and never page without a runbook_url.
  • Set for to at least two scrape intervals so a single missed scrape can't page; add keep_firing_for on noisy thresholds.
  • Template annotations freely ({{ $labels.namespace }}, {{ $value | humanize }}, {{ $value | humanizePercentage }}, {{ $externalLabels.cluster }}), but avoid putting volatile values like $value inside labels, because changing label values mints a fresh alert identity every cycle and breaks grouping.
  • Audit alert noise with Prometheus's built-in ALERTS{alertname, alertstate="pending|firing"} series: count by (alertname) (changes(ALERTS[7d])).
  • Watch Alertmanager itself via alertmanager_notifications_failed_total, alertmanager_alerts_invalid_total, and your Watchdog heartbeat.

Unit-test rules before deploying them

Run promtool check rules rules.yml for syntax and promtool test rules test.yml to simulate real time series without breaking production. A test file loads your rule files, sets an evaluation_interval, feeds synthetic input_series (using shorthand like 0+10x5: start at 0, add 10 five times), and asserts exact firing alerts (alert_rule_test) or PromQL results (promql_expr_test) at specific timestamps. To test a PrometheusRule CRD, just extract spec.groups into a YAML file.

rule_files: [rules.yml]
evaluation_interval: 1m
tests:
  - interval: 1m
    input_series:
      - series: 'up{job="payments", instance="a"}'
        values: '1 1 0 0 0 0 0'
    alert_rule_test:
      - alertname: PaymentsDown
        eval_time: 6m
        exp_alerts:
          - exp_labels: { severity: critical, job: payments, instance: a }
            exp_annotations: { summary: "payments target a is down" }
How this gets tested

"Alert if error rate crosses X for Y minutes, route severity="critical" to receiver Z, and keep weekends quiet" translates directly to three pieces: a PrometheusRule with for and severity, an Alertmanager route with matchers and receiver, and a time_intervals entry wired into mute_time_intervals. Verify immediately with amtool config routes test and the rendered config.

Exercises

tick the dot when its check passes

Alertmanager has no LoadBalancer here: kubectl -n monitoring port-forward svc/prometheus-kube-prometheus-alertmanager 9093:9093 and browse localhost:9093.

kubectl apply -f - <<'EOF'
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: curriculum-drill
  namespace: monitoring
  labels: { release: prometheus }
spec:
  groups:
    - name: drill
      rules:
        - alert: TooManyExamplePods
          expr: count(kube_pod_info{namespace="default"}) > 0
          for: 1m
          labels: { severity: warning, team: platform }
          annotations:
            summary: "{{ $value }} pods in default"
            description: "Drill alert; fires whenever default has any pods."
EOF
outputcaptured 2026-08-26
$ kubectl apply -f - <<'EOF'
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: curriculum-drill
  namespace: monitoring
  labels: { release: prometheus }
spec:
  groups:
    - name: drill
      rules:
        - alert: TooManyExamplePods
          expr: count(kube_pod_info{namespace="default"}) > 0
          for: 1m
          labels: { severity: warning, team: platform }
          annotations:
            summary: "{{ $value }} pods in default"
            description: "Drill alert; fires whenever default has any pods."
EOF
prometheusrule.monitoring.coreos.com/curriculum-drill created

Watch it walk the states: Prometheus UI → Alerts shows Pending, then Firing after the minute.

verify: it appears in the Alertmanager UI with your labels, grouped, and the annotation rendered the live value rather than the template text.

In the Alertmanager UI, create a silence matching alertname=TooManyExamplePods for 2 hours with a comment.

verify: the alert leaves the active view and lands under Silences, while Prometheus still shows it Firing. That split is the lesson: silencing changes notification, never truth.

Open Status in the Alertmanager UI and answer from the rendered config: what is the root receiver, what does group_by collapse on, which special route exists for the Watchdog alert (the stack ships one that fires always, as a dead-man's switch; know why that is a feature).

verify: you can trace where your drill alert's severity: warning lands in the tree and say which single config line you would change to route team: platform alerts to a new webhook receiver.

Deploy a trivial webhook sink (kubectl create deploy sink --image=mendhak/http-https-echo:31 plus a Service), add an AlertmanagerConfig in default routing team: platform to it, then verify pickup: does the rendered config in the UI now contain the route? If yes, kubectl logs deploy/sink shows the JSON payload when the drill alert fires. Read it once; its structure (groupLabels, commonAnnotations, alerts[]) is what every receiver integration parses.

verify: either the payload arrives, or you can name the selector on the Alertmanager object that would have to change. Clean up: delete the PrometheusRule; the silence expires on its own.

A silence is a manual action with an end time. A mute time interval is policy: this route does not page on weekends, forever. Tasks ask for the second and people reach for the first.

kubectl apply -f - <<'EOF'
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata: { name: quiet-hours, namespace: default, labels: { release: prometheus } }
spec:
  route:
    groupBy: [alertname]
    receiver: blackhole
    muteTimeIntervals: [always-now]
  receivers:
    - name: blackhole
  muteTimeIntervals:
    - name: always-now
      timeIntervals:
        - times:
            - { startTime: "00:00", endTime: "24:00" }
EOF
sleep 90
kubectl -n monitoring get secret alertmanager-prometheus-kube-prometheus-alertmanager-generated -o jsonpath='{.data.alertmanager\.yaml\.gz}' | base64 -d | gunzip | sed -n '/mute_time_intervals/,/^[a-z]/p'
kubectl -n monitoring exec sts/alertmanager-prometheus-kube-prometheus-alertmanager -c alertmanager -- sh -c 'amtool config routes test --config.file=/etc/alertmanager/config_out/alertmanager.env.yaml alertname=TooManyExamplePods severity=warning namespace=default'
kubectl -n default delete alertmanagerconfig quiet-hours
outputcaptured 2026-09-13
$ kubectl apply -f - <<'EOF'
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata: { name: quiet-hours, namespace: default, labels: { release: prometheus } }
spec:
  route:
    groupBy: [alertname]
    receiver: blackhole
    muteTimeIntervals: [always-now]
  receivers:
    - name: blackhole
  muteTimeIntervals:
    - name: always-now
      timeIntervals:
        - times:
            - { startTime: "00:00", endTime: "24:00" }
EOF
alertmanagerconfig.monitoring.coreos.com/quiet-hours created
$ sleep 90
$ kubectl -n monitoring get secret alertmanager-prometheus-kube-prometheus-alertmanager-generated -o jsonpath='{.data.alertmanager\.yaml\.gz}' | base64 -d | gunzip | sed -n '/mute_time_intervals/,/^[a-z]/p'
    mute_time_intervals:
    - default/quiet-hours/always-now
  - receiver: "null"
    matchers:
    - alertname = "Watchdog"
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 12h
inhibit_rules:
mute_time_intervals:
- name: default/quiet-hours/always-now
  time_intervals:
  - times:
    - start_time: "00:00"
      end_time: "24:00"
templates:
$ kubectl -n monitoring exec sts/alertmanager-prometheus-kube-prometheus-alertmanager -c alertmanager -- sh -c 'amtool config routes test --config.file=/etc/alertmanager/config_out/alertmanager.env.yaml alertname=TooManyExamplePods severity=warning namespace=default'
default/quiet-hours/blackhole
$ kubectl -n default delete alertmanagerconfig quiet-hours
alertmanagerconfig.monitoring.coreos.com "quiet-hours" deleted from default namespace
verify: the rendered config contains your interval and the route that references it, and amtool config routes test names the receiver a matching alert would land on.

When the cluster is on fire you want one page, not forty. An inhibition rule suppresses warnings while a related critical is firing, matched on a shared label, and getting that equal list right is the entire skill.

kubectl apply -f - <<'EOF'
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata: { name: inhibit-demo, namespace: default, labels: { release: prometheus } }
spec:
  route:
    groupBy: [alertname]
    receiver: blackhole
  receivers:
    - name: blackhole
  inhibitRules:
    - sourceMatch:
        - { name: alertname, value: DrillOutage }
      targetMatch:
        - { name: severity, value: warning }
      equal: [namespace]
EOF
sleep 120
kubectl -n monitoring get secret alertmanager-prometheus-kube-prometheus-alertmanager-generated -o jsonpath='{.data.alertmanager\.yaml\.gz}' | base64 -d | gunzip | grep -B4 -A4 DrillOutage
kubectl -n monitoring port-forward svc/prometheus-kube-prometheus-alertmanager 9093:9093 & PF1=$!
sleep 5
# Watchdog and the drill alert carry no namespace label, and the CRD adds namespace to both matchers,
# so nothing cluster-generated can ever match: inject a pair that can
curl -s -XPOST localhost:9093/api/v2/alerts -H 'Content-Type: application/json' -d '[{"labels":{"alertname":"DrillOutage","severity":"critical","namespace":"default"}},{"labels":{"alertname":"DrillNoise","severity":"warning","namespace":"default"}}]'
sleep 45
curl -s localhost:9093/api/v2/alerts | jq '[.[] | select(.labels.alertname|startswith("Drill")) | {alertname: .labels.alertname, state: .status.state, inhibitedBy: .status.inhibitedBy}]'
kill $PF1
kubectl -n default delete alertmanagerconfig inhibit-demo
outputcaptured 2026-09-13
$ kubectl apply -f - <<'EOF'
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata: { name: inhibit-demo, namespace: default, labels: { release: prometheus } }
spec:
  route:
    groupBy: [alertname]
    receiver: blackhole
  receivers:
    - name: blackhole
  inhibitRules:
    - sourceMatch:
        - { name: alertname, value: DrillOutage }
      targetMatch:
        - { name: severity, value: warning }
      equal: [namespace]
EOF
alertmanagerconfig.monitoring.coreos.com/inhibit-demo created
$ sleep 120
$ kubectl -n monitoring get secret alertmanager-prometheus-kube-prometheus-alertmanager-generated -o jsonpath='{.data.alertmanager\.yaml\.gz}' | base64 -d | gunzip | grep -B4 -A4 DrillOutage
- target_matchers:
  - severity="warning"
  - namespace="default"
  source_matchers:
  - alertname="DrillOutage"
  - namespace="default"
  equal:
  - namespace
receivers:
$ kubectl -n monitoring port-forward svc/prometheus-kube-prometheus-alertmanager 9093:9093 & PF1=$!
$ sleep 5
Forwarding from 127.0.0.1:9093 -> 9093
Forwarding from [::1]:9093 -> 9093
$ # Watchdog and the drill alert carry no namespace label, and the CRD adds namespace to both matchers,
$ # so nothing cluster-generated can ever match: inject a pair that can
$ curl -s -XPOST localhost:9093/api/v2/alerts -H 'Content-Type: application/json' -d '[{"labels":{"alertname":"DrillOutage","severity":"critical","namespace":"default"}},{"labels":{"alertname":"DrillNoise","severity":"warning","namespace":"default"}}]'
Handling connection for 9093
$ sleep 45
$ curl -s localhost:9093/api/v2/alerts | jq '[.[] | select(.labels.alertname|startswith("Drill")) | {alertname: .labels.alertname, state: .status.state, inhibitedBy: .status.inhibitedBy}]'
Handling connection for 9093
[
  {
    "alertname": "DrillNoise",
    "state": "suppressed",
    "inhibitedBy": [
      "f3637fb5c13520d0"
    ]
  },
  {
    "alertname": "DrillOutage",
    "state": "active",
    "inhibitedBy": []
  }
]
$ kill $PF1
$ kubectl -n default delete alertmanagerconfig inhibit-demo
alertmanagerconfig.monitoring.coreos.com "inhibit-demo" deleted from default namespace
verify: the rendered config carries your rule with namespace="default" added to both matchers by the CRD, and DrillNoise comes back with inhibitedBy naming DrillOutage's fingerprint while DrillOutage itself has an empty list. Both injected alerts carry a namespace label on purpose: the stock Watchdog alert has none, so a rule that equals on namespace can never match it.

Alerting rules are code and can be tested without waiting for reality to cooperate. promtool test rules feeds synthetic series in and asserts which alerts fire, which is the only way to be sure about a for clause.

kubectl -n monitoring delete pod promtool-check --ignore-not-found
kubectl apply -f - <<'EOF'
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: curriculum-drill
  namespace: monitoring
  labels: { release: prometheus }
spec:
  groups:
    - name: drill
      rules:
        - alert: TooManyExamplePods
          expr: count(kube_pod_info{namespace="default"}) > 0
          for: 1m
          labels: { severity: warning, team: platform }
          annotations:
            summary: "{{ $value }} pods in default"
            description: "Drill alert; fires whenever default has any pods."
EOF
kubectl -n monitoring get prometheusrule curriculum-drill -o jsonpath='{.spec}' | jq '{groups: .groups}' > /tmp/rules.json
python3 -c "import json,yaml; print(yaml.safe_dump(json.load(open('/tmp/rules.json'))))" > /tmp/rules.yml
cat /tmp/rules.yml
cat > /tmp/test.yml <<'EOF'
rule_files:
  - rules.yml
evaluation_interval: 1m
tests:
  - interval: 1m
    input_series:
      - series: 'kube_pod_info{namespace="default",pod="p1"}'
        values: '1+0x10'
    alert_rule_test:
      - eval_time: 30s
        alertname: TooManyExamplePods
        exp_alerts: []
      - eval_time: 5m
        alertname: TooManyExamplePods
        exp_alerts:
          - exp_labels:
              severity: warning
              team: platform
            exp_annotations:
              summary: "1 pods in default"
              description: "Drill alert; fires whenever default has any pods."
EOF
kubectl -n monitoring create configmap promtool-test --from-file=rules.yml=/tmp/rules.yml --from-file=test.yml=/tmp/test.yml --dry-run=client -o yaml | kubectl apply -f -
IMG=$(kubectl -n monitoring get sts prometheus-prometheus-kube-prometheus-prometheus -o jsonpath='{.spec.template.spec.containers[?(@.name=="prometheus")].image}'); echo "$IMG"
kubectl -n monitoring run promtool-check --rm -i --restart=Never --image="$IMG" --overrides="{\"spec\":{\"containers\":[{\"name\":\"promtool-check\",\"image\":\"$IMG\",\"workingDir\":\"/t\",\"command\":[\"promtool\",\"check\",\"rules\",\"rules.yml\"],\"volumeMounts\":[{\"name\":\"t\",\"mountPath\":\"/t\"}]}],\"volumes\":[{\"name\":\"t\",\"configMap\":{\"name\":\"promtool-test\"}}]}}"
kubectl -n monitoring run promtool-unit --rm -i --restart=Never --image="$IMG" --overrides="{\"spec\":{\"containers\":[{\"name\":\"promtool-unit\",\"image\":\"$IMG\",\"workingDir\":\"/t\",\"command\":[\"promtool\",\"test\",\"rules\",\"test.yml\"],\"volumeMounts\":[{\"name\":\"t\",\"mountPath\":\"/t\"}]}],\"volumes\":[{\"name\":\"t\",\"configMap\":{\"name\":\"promtool-test\"}}]}}"
kubectl -n monitoring delete configmap promtool-test
# otherwise TooManyExamplePods fires on this cluster forever
kubectl -n monitoring delete prometheusrule curriculum-drill
kubectl -n monitoring delete pod promtool-check --ignore-not-found
outputcaptured 2026-11-18
$ kubectl -n monitoring delete pod promtool-check --ignore-not-found
$ kubectl apply -f - <<'EOF'
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: curriculum-drill
  namespace: monitoring
  labels: { release: prometheus }
spec:
  groups:
    - name: drill
      rules:
        - alert: TooManyExamplePods
          expr: count(kube_pod_info{namespace="default"}) > 0
          for: 1m
          labels: { severity: warning, team: platform }
          annotations:
            summary: "{{ $value }} pods in default"
            description: "Drill alert; fires whenever default has any pods."
EOF
prometheusrule.monitoring.coreos.com/curriculum-drill created
$ kubectl -n monitoring get prometheusrule curriculum-drill -o jsonpath='{.spec}' | jq '{groups: .groups}' > /tmp/rules.json
$ python3 -c "import json,yaml; print(yaml.safe_dump(json.load(open('/tmp/rules.json'))))" > /tmp/rules.yml
$ cat /tmp/rules.yml
groups:
- name: drill
  rules:
  - alert: TooManyExamplePods
    annotations:
      description: Drill alert; fires whenever default has any pods.
      summary: '{{ $value }} pods in default'
    expr: count(kube_pod_info{namespace="default"}) > 0
    for: 1m
    labels:
      severity: warning
      team: platform
$ cat > /tmp/test.yml <<'EOF'
rule_files:
  - rules.yml
evaluation_interval: 1m
tests:
  - interval: 1m
    input_series:
      - series: 'kube_pod_info{namespace="default",pod="p1"}'
        values: '1+0x10'
    alert_rule_test:
      - eval_time: 30s
        alertname: TooManyExamplePods
        exp_alerts: []
      - eval_time: 5m
        alertname: TooManyExamplePods
        exp_alerts:
          - exp_labels:
              severity: warning
              team: platform
            exp_annotations:
              summary: "1 pods in default"
              description: "Drill alert; fires whenever default has any pods."
EOF
$ kubectl -n monitoring create configmap promtool-test --from-file=rules.yml=/tmp/rules.yml --from-file=test.yml=/tmp/test.yml --dry-run=client -o yaml | kubectl apply -f -
configmap/promtool-test created
$ IMG=$(kubectl -n monitoring get sts prometheus-prometheus-kube-prometheus-prometheus -o jsonpath='{.spec.template.spec.containers[?(@.name=="prometheus")].image}'); echo "$IMG"
quay.io/prometheus/prometheus:v3.16.0-distroless
$ kubectl -n monitoring run promtool-check --rm -i --restart=Never --image="$IMG" --overrides="{\"spec\":{\"containers\":[{\"name\":\"promtool-check\",\"image\":\"$IMG\",\"workingDir\":\"/t\",\"command\":[\"promtool\",\"check\",\"rules\",\"rules.yml\"],\"volumeMounts\":[{\"name\":\"t\",\"mountPath\":\"/t\"}]}],\"volumes\":[{\"name\":\"t\",\"configMap\":{\"name\":\"promtool-test\"}}]}}"
Checking rules.yml
  SUCCESS: 1 rules found

All commands and output from this session will be recorded in container logs, including credentials and sensitive information passed through the command prompt.
If you don't see a command prompt, try pressing enter.
warning: couldn't attach to pod/promtool-check, falling back to streaming logs: unable to upgrade connection: container promtool-check not found in pod promtool-check_monitoring
Checking rules.yml
  SUCCESS: 1 rules found

pod "promtool-check" deleted from monitoring namespace
$ kubectl -n monitoring run promtool-unit --rm -i --restart=Never --image="$IMG" --overrides="{\"spec\":{\"containers\":[{\"name\":\"promtool-unit\",\"image\":\"$IMG\",\"workingDir\":\"/t\",\"command\":[\"promtool\",\"test\",\"rules\",\"test.yml\"],\"volumeMounts\":[{\"name\":\"t\",\"mountPath\":\"/t\"}]}],\"volumes\":[{\"name\":\"t\",\"configMap\":{\"name\":\"promtool-test\"}}]}}"
Processing test file: test.yml
  SUCCESS

All commands and output from this session will be recorded in container logs, including credentials and sensitive information passed through the command prompt.
If you don't see a command prompt, try pressing enter.
warning: couldn't attach to pod/promtool-unit, falling back to streaming logs: unable to upgrade connection: container promtool-unit not found in pod promtool-unit_monitoring
pod "promtool-unit" deleted from monitoring namespace
$ kubectl -n monitoring delete configmap promtool-test
configmap "promtool-test" deleted from monitoring namespace
$ # otherwise TooManyExamplePods fires on this cluster forever
$ kubectl -n monitoring delete prometheusrule curriculum-drill
prometheusrule.monitoring.coreos.com "curriculum-drill" deleted from monitoring namespace
$ kubectl -n monitoring delete pod promtool-check --ignore-not-found
verify: check rules passes and test rules reports SUCCESS, including the case at 30 seconds where the for clause has not elapsed. Change the for to 10m and watch the same test fail; that is the assertion earning its keep.

A good availability alert fires fast on a big burn and slow on a small one, and it does that with two windows over the same ratio. Build it on a recording rule so the alert expression stays readable.

kubectl apply -f - <<'EOF'
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata: { name: burn-rate, namespace: monitoring, labels: { release: prometheus } }
spec:
  groups:
    - name: sli
      interval: 30s
      rules:
        - record: job:request_error_ratio:rate5m
          expr: |
            sum(rate(apiserver_request_total{code=~"5.."}[5m]))
            /
            sum(rate(apiserver_request_total[5m]))
        - record: job:request_error_ratio:rate1h
          expr: |
            sum(rate(apiserver_request_total{code=~"5.."}[1h]))
            /
            sum(rate(apiserver_request_total[1h]))
        - alert: ErrorBudgetBurn
          expr: |
            job:request_error_ratio:rate5m > (14.4 * 0.001)
            and
            job:request_error_ratio:rate1h > (14.4 * 0.001)
          for: 2m
          labels: { severity: critical, team: platform }
          annotations:
            summary: "burning the error budget 14.4x faster than allowed"
EOF
sleep 120
kubectl -n monitoring port-forward svc/prometheus-kube-prometheus-prometheus 9090:9090 & PF1=$!
sleep 5
curl -sG localhost:9090/api/v1/query --data-urlencode 'query=job:request_error_ratio:rate5m' | jq '.data.result[0].value[1]'
curl -s localhost:9090/api/v1/rules | jq '.data.groups[] | select(.name=="sli") | .rules[] | {name: (.name // .alert), type, health, state}'
kill $PF1
kubectl -n monitoring delete prometheusrule burn-rate
outputcaptured 2026-09-12
$ kubectl apply -f - <<'EOF'
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata: { name: burn-rate, namespace: monitoring, labels: { release: prometheus } }
spec:
  groups:
    - name: sli
      interval: 30s
      rules:
        - record: job:request_error_ratio:rate5m
          expr: |
            sum(rate(apiserver_request_total{code=~"5.."}[5m]))
            /
            sum(rate(apiserver_request_total[5m]))
        - record: job:request_error_ratio:rate1h
          expr: |
            sum(rate(apiserver_request_total{code=~"5.."}[1h]))
            /
            sum(rate(apiserver_request_total[1h]))
        - alert: ErrorBudgetBurn
          expr: |
            job:request_error_ratio:rate5m > (14.4 * 0.001)
            and
            job:request_error_ratio:rate1h > (14.4 * 0.001)
          for: 2m
          labels: { severity: critical, team: platform }
          annotations:
            summary: "burning the error budget 14.4x faster than allowed"
EOF
prometheusrule.monitoring.coreos.com/burn-rate created
$ sleep 120
$ kubectl -n monitoring port-forward svc/prometheus-kube-prometheus-prometheus 9090:9090 & PF1=$!
$ sleep 5
Forwarding from 127.0.0.1:9090 -> 9090
Forwarding from [::1]:9090 -> 9090
$ curl -sG localhost:9090/api/v1/query --data-urlencode 'query=job:request_error_ratio:rate5m' | jq '.data.result[0].value[1]'
Handling connection for 9090
"0"
$ curl -s localhost:9090/api/v1/rules | jq '.data.groups[] | select(.name=="sli") | .rules[] | {name: (.name // .alert), type, health, state}'
Handling connection for 9090
{
  "name": "job:request_error_ratio:rate5m",
  "type": "recording",
  "health": "ok",
  "state": null
}
{
  "name": "job:request_error_ratio:rate1h",
  "type": "recording",
  "health": "ok",
  "state": null
}
{
  "name": "ErrorBudgetBurn",
  "type": "alerting",
  "health": "ok",
  "state": "inactive"
}
$ kill $PF1
$ kubectl -n monitoring delete prometheusrule burn-rate
prometheusrule.monitoring.coreos.com "burn-rate" deleted from monitoring namespace
verify: both recording rules are healthy and the alert is inactive on a quiet cluster.

The AlertmanagerConfig objects you write are merged into one file by the operator, with a namespace matcher injected into every route. Reading the rendered result is how you find out what your object became.

# nothing of yours is in the rendered file until an AlertmanagerConfig exists
kubectl apply -f - <<'EOF'
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata: { name: read-me, namespace: default, labels: { release: prometheus } }
spec:
  route:
    groupBy: [alertname]
    receiver: mine
  receivers:
    - name: mine
EOF
sleep 60
kubectl -n monitoring get secret alertmanager-prometheus-kube-prometheus-alertmanager-generated -o jsonpath='{.data.alertmanager\.yaml\.gz}' | base64 -d | gunzip | head -60
kubectl -n monitoring get alertmanagerconfig -A
kubectl -n monitoring get alertmanager -o jsonpath='{.items[0].spec.alertmanagerConfigSelector}{"\n"}'
kubectl -n default delete alertmanagerconfig read-me
outputcaptured 2026-09-12
$ # nothing of yours is in the rendered file until an AlertmanagerConfig exists
$ kubectl apply -f - <<'EOF'
apiVersion: monitoring.coreos.com/v1alpha1
kind: AlertmanagerConfig
metadata: { name: read-me, namespace: default, labels: { release: prometheus } }
spec:
  route:
    groupBy: [alertname]
    receiver: mine
  receivers:
    - name: mine
EOF
alertmanagerconfig.monitoring.coreos.com/read-me created
$ sleep 60
$ kubectl -n monitoring get secret alertmanager-prometheus-kube-prometheus-alertmanager-generated -o jsonpath='{.data.alertmanager\.yaml\.gz}' | base64 -d | gunzip | head -60
global:
  resolve_timeout: 5m
route:
  receiver: "null"
  group_by:
  - namespace
  routes:
  - receiver: default/read-me/mine
    group_by:
    - alertname
    matchers:
    - namespace="default"
    continue: true
  - receiver: "null"
    matchers:
    - alertname = "Watchdog"
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 12h
inhibit_rules:
- target_matchers:
  - severity =~ warning|info
  source_matchers:
  - severity = critical
  equal:
  - namespace
  - alertname
- target_matchers:
  - severity = info
  source_matchers:
  - severity = warning
  equal:
  - namespace
  - alertname
- target_matchers:
  - severity = info
  source_matchers:
  - alertname = InfoInhibitor
  equal:
  - namespace
... 7 more lines
$ kubectl -n monitoring get alertmanagerconfig -A
NAMESPACE   NAME      AGE
default     read-me   60s
$ kubectl -n monitoring get alertmanager -o jsonpath='{.items[0].spec.alertmanagerConfigSelector}{"\n"}'
{}
$ kubectl -n default delete alertmanagerconfig read-me
alertmanagerconfig.monitoring.coreos.com "read-me" deleted from default namespace
verify: the rendered file carries a route you never typed: your read-me config appears with namespace = "default" added to its matchers, and its receiver is renamed default/read-me/mine, prefixed with the namespace and the object name. That prefixing is why a receiver name in your object does not match the one in the UI. Without an AlertmanagerConfig of your own there is nothing of yours in the file, only the chart's null receiver and the stock inhibit rules.

Prometheus does not notify anyone; it posts to Alertmanager, and the discovery for that is in the Prometheus object rather than anywhere in your rules. On a cluster with alerts that never arrive, this is the second thing to check after the rule itself.

kubectl -n monitoring get prometheus -o jsonpath='{.items[0].spec.alerting}' | jq
kubectl -n monitoring port-forward svc/prometheus-kube-prometheus-prometheus 9090:9090 & PF1=$!
sleep 5
curl -s localhost:9090/api/v1/alertmanagers | jq '{active: [.data.activeAlertmanagers[].url], dropped: [.data.droppedAlertmanagers[].url]}'
kill $PF1
outputcaptured 2026-09-12
$ kubectl -n monitoring get prometheus -o jsonpath='{.items[0].spec.alerting}' | jq
{
  "alertmanagers": [
    {
      "apiVersion": "v2",
      "name": "prometheus-kube-prometheus-alertmanager",
      "namespace": "monitoring",
      "pathPrefix": "/",
      "port": "http-web"
    }
  ]
}
$ kubectl -n monitoring port-forward svc/prometheus-kube-prometheus-prometheus 9090:9090 & PF1=$!
$ sleep 5
Forwarding from 127.0.0.1:9090 -> 9090
Forwarding from [::1]:9090 -> 9090
$ curl -s localhost:9090/api/v1/alertmanagers | jq '{active: [.data.activeAlertmanagers[].url], dropped: [.data.droppedAlertmanagers[].url]}'
Handling connection for 9090
{
  "active": [
    "http://10.244.2.68:9093/api/v2/alerts"
  ],
  "dropped": [
    "http://10.244.2.242:7946/api/v2/alerts",
    "http://10.244.2.242:3100/api/v2/alerts",
    "http://10.244.2.242:9095/api/v2/alerts",
    "http://10.244.1.157:12345/api/v2/alerts",
    "http://10.244.2.3:10250/api/v2/alerts",
    "http://10.244.1.103:9090/api/v2/alerts",
    "http://10.244.1.103:8080/api/v2/alerts",
    "http://10.244.1.103:8081/api/v2/alerts",
    "http://10.244.2.192:9115/api/v2/alerts",
    "http://10.244.2.68:8080/api/v2/alerts",
    "http://10.244.2.68:9094/api/v2/alerts",
    "http://10.244.2.68:9094/api/v2/alerts",
    "http://10.244.2.68:8081/api/v2/alerts",
    "http://10.244.2.160:8080/api/v2/alerts",
    "http://172.18.0.3:9100/api/v2/alerts",
    "http://172.18.0.4:9100/api/v2/alerts",
    "http://172.18.0.5:9100/api/v2/alerts",
    "http://10.244.1.75:3000/api/v2/alerts",
    "http://10.244.1.75:9094/api/v2/alerts",
    "http://10.244.1.75:9094/api/v2/alerts",
    "http://10.244.1.75:6060/api/v2/alerts",
    "http://10.244.2.68:9094/api/v2/alerts",
    "http://10.244.2.68:9094/api/v2/alerts",
    "http://10.244.2.68:9093/api/v2/alerts",
    "http://10.244.2.68:8080/api/v2/alerts",
    "http://10.244.2.68:8081/api/v2/alerts",
    "http://10.244.1.103:9090/api/v2/alerts",
    "http://10.244.1.103:8080/api/v2/alerts",
    "http://10.244.1.103:8081/api/v2/alerts",
    "http://10.244.2.184:8080/api/v2/alerts",
    "http://10.244.2.184:8081/api/v2/alerts",
    "http://10.244.2.242:3100/api/v2/alerts",
    "http://10.244.2.160:8080/api/v2/alerts",
    "http://10.244.2.242:9095/api/v2/alerts",
... 6 more lines
$ kill $PF1
verify: the spec names the Alertmanager Service and port, and the API confirms at least one active endpoint. An empty active list with healthy rules is the whole diagnosis for "it says firing but nobody was paged".

Self-check

answer before opening
An alert shows Firing in Prometheus and nothing arrived. Three candidate causes?

An active silence matches it, an inhibition rule is suppressing it, or its receiver is failing (check Alertmanager logs and alertmanager_notifications_failed_total). And if it only just flipped to Firing, group_wait might simply still be ticking down.

Your rule applies cleanly and never evaluates. What did you not check?

The Prometheus CR's ruleSelector and ruleNamespaceSelector. Unmatched rules are ignored with zero errors, just like ServiceMonitors, so always read the selector first.

Silence versus inhibition: when do you use each?

Use a silence for temporary, human-driven muting (like a maintenance window) with an expiry and comment. Use inhibition as a standing architectural rule that suppresses noisy downstream symptoms whenever a bigger upstream alarm is already firing.

How long, roughly, from "condition becomes true" to "notification sent" on a stock stack?

Up to one evaluation interval (30s) + your for duration (say 1–5m) + group_wait (30s), easily 2–3 minutes at minimum. That's why you wait before declaring alerting broken, and why for: 15m is usually too sluggish for page-worthy outages.

What is the Watchdog alert for?

It fires continuously as a dead-man's switch. An external monitor expects to keep receiving it and pages you if it stops, catching the case where Prometheus or Alertmanager itself goes down and can't alert on anything.

"Notify the database team only during business hours, page everyone else at any time." Which fields carry that?

Define a top-level time_intervals window (times: 09:00-17:00, weekdays: monday:friday, plus location) and attach active_time_intervals: [business_hours] to the database route so notifications pause outside those hours while other routes fire 24/7. (mute_time_intervals is the inverse, and mute wins if both appear.)

A team's AlertmanagerConfig in namespace team-a routes alertname="NodeDown" to their webhook, is selected, appears in the rendered config, and never fires. Why?

The operator automatically scopes merged namespaced AlertmanagerConfig routes with namespace="team-a". Because NodeDown is a cluster-level alert carrying no namespace label, the route can never match it. Route cluster-wide alerts through global config (spec.configSecret or spec.alertmanagerConfiguration).

Explain the 14.4 in a burn-rate alert and why the rule has two windows.

A burn rate of 14.4 consumes 2% of a 30-day error budget in one hour (30 × 24 × 0.02 = 14.4). Pairing a long window (1h) with a short window (5m) via and confirms the burn is sustained while letting the alert clear quickly as soon as the issue recovers.

How do you prove a new alerting rule fires under the right conditions without waiting for production to break?

Run promtool test rules with synthetic input_series and alert_rule_test assertions checking expected labels and annotations at specific timestamps. Pair it with promtool check rules for syntax and amtool config routes test to verify routing.

Docs to know your way around

study time, not exam time
  • prometheus.io: alerting rules, and the Alertmanager configuration page (route and inhibit_rule syntax).
  • prometheus-operator.dev: PrometheusRule and AlertmanagerConfig CRD references.
  • sre.google: the SRE workbook chapter on alerting on SLOs, for burn-rate vocabulary.
  • Offline: amtool config routes show / amtool config routes test if the binary is present, and the Alertmanager UI's Status page.
  • prometheus.io/docs/alerting/latest/configuration: the <route>, <inhibit_rule> and <time_interval> sections are the ones to have bookmarked; note which keys are deprecated.
  • prometheus.io/docs/prometheus/latest/configuration/unit_testing_rules: the promtool test rules file format; sre.google/workbook/alerting-on-slos for the burn-rate table.
  • prometheus-operator.dev/docs/developer/alerting: the three ways to configure the Alertmanager object and the namespace-scoping rule for merged AlertmanagerConfigs.