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).
More on Alerting Strategy, SLOs & Runbooks
What is the single most important rule for deciding whether an alert should page a human?BeginnerWhat severity levels do you define, and where does each one go?BeginnerWhy do mature teams alert on SLO burn rate instead of raw error rate thresholds?IntermediateIn a multi-window burn-rate alert, what is the short window for?AdvancedHow do you generate SLO alert rules without hand-writing dozens of burn-rate expressions?IntermediateHow do you pick an SLO target for a service that has never had one?Beginner