Interview Prep/Monitoring & Observability/Alerting Strategy, SLOs & Runbooks

How do you use `for:` and `keep_firing_for:` correctly in alert rules?

IntermediateProductionAlerting Strategy, SLOs & Runbooks
Answer

for: requires the condition to be true continuously for that long before the alert moves from pending to firing; it removes blips. keep_firing_for: (Prometheus 2.42+) keeps the alert firing for a while after the condition clears, which stops flapping resolve/re-fire notifications.

- alert: QueueBacklogHigh
  expr: queue_depth > 10000
  for: 10m
  keep_firing_for: 15m

Keep for: short on burn-rate alerts (the windows already smooth), and remember a Prometheus restart resets pending state unless rule state restoration applies (it does for for up to --rules.alert.for-outage-tolerance).

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Alerting Strategy, SLOs & Runbooks