Writing Alerts Worth Waking Up For
The tools make it easy to write a hundred alerts. The hard part is a set of alerts where every page is real, urgent and actionable, and nothing important is missed. Teams that get this wrong end up with alert fatigue: pages ignored, muted channels, and the one real incident lost in the noise.
Page on symptoms, not causes
| Symptom (users feel it) | Cause (might matter) |
|---|---|
| error ratio above 5% for 5 minutes | a pod restarted |
| p99 latency above the SLO | CPU at 90% |
| redirects dropped to zero | Redis replica lag |
| probe from outside fails | one node NotReady |
A cause-based alert fires when nothing is wrong for users (CPU at 90% with fine latency is just efficient), and stays silent on failures you didn't predict. Symptom alerts catch every cause, including unknown ones. Causes belong on dashboards and in ticket-level alerts that someone handles during working hours.
Three levels, three channels
| Severity | Meaning | Route |
|---|---|---|
page |
users are affected now, or will be within hours; needs a human immediately | PagerDuty / Opsgenie, phone |
ticket |
must be fixed in days: disk filling in a week, certificate expires in 14 days, a backup failed once | a ticket queue or a team channel |
info |
context for investigations, no action | dashboards only, or a low-traffic channel |
Every page alert should pass four questions: Is it urgent? Is it actionable (is there something a human can do)? Is it user-visible or imminent? Would we be fine not knowing until morning? If the last answer is yes, it's a ticket.
Make each alert self-explanatory
The person reading it is half-awake. Give them:
- a
summarywith the numbers (5xx ratio 12% on linkly (threshold 5%)), not "error rate high"; - a
descriptionwith the scope: which service, environment, region; - a
runbook_url: what to check first, how to mitigate, who to escalate to (SRE: runbooks); - a
dashboardlink pre-filtered to the service and time.
Thresholds, windows and flapping
Noisy signals cross a fixed threshold many times. The model below generates a day of per-minute error ratios with normal noise and one real 40-minute incident (which briefly dips below the threshold), and counts how many notifications different rules would send (one per transition into firing):
import random
random.seed(11)
minutes = 24 * 60
ratio = []
for m in range(minutes):
base = 0.01 + random.random() * 0.03 # normal: 1-4% errors
if random.random() < 0.02:
base += 0.05 # a one-minute blip, ~30 per day
if 600 <= m < 640 and m not in (612, 613):
base = 0.12 # the real incident (with a two-minute dip)
ratio.append(base)
def notifications(threshold, for_minutes, keep_firing=0):
pages, pending, firing, quiet = [], 0, False, 0
for m, r in enumerate(ratio):
if r > threshold:
pending += 1
quiet = 0
if not firing and pending > for_minutes:
firing = True
pages.append(m)
else:
pending = 0
quiet += 1
if firing and quiet > keep_firing:
firing = False
return pages
for threshold, for_m, keep in ((0.05, 0, 0), (0.05, 2, 0), (0.05, 5, 0), (0.05, 5, 10), (0.15, 5, 0)):
p = notifications(threshold, for_m, keep)
during = [m for m in p if 600 <= m < 640]
print(f"> {threshold:.0%} for {for_m}m keep {keep:2}m: {len(p):3} pages in total, "
+ (f"incident pages at minutes {during}" if during else "incident MISSED"))> 5% for 0m keep 0m: 21 pages in total, incident pages at minutes [600, 614]
> 5% for 2m keep 0m: 2 pages in total, incident pages at minutes [602, 616]
> 5% for 5m keep 0m: 2 pages in total, incident pages at minutes [605, 619]
> 5% for 5m keep 10m: 1 pages in total, incident pages at minutes [605]
> 15% for 5m keep 0m: 0 pages in total, incident MISSED
With no for, every blip pages someone: 21 pages for one incident. A few minutes of for removes the blips while still catching the incident, at the cost of detection delay. The two-minute dip in the middle of the incident resolves the alert and pages again; keep_firing_for turns that into one page. A threshold set too high to "reduce noise" misses the incident entirely. In real systems the noise is much less regular than this model; that's why SLO-based multi-window burn-rate alerts (fire when the error budget burns fast over both a long and a short window) are the standard for availability and latency. They are built in SRE: burn-rate alerts on top of this course's recording rules.
Alerts you always need
| Alert | Why |
|---|---|
absent(up{job="X"}) / up == 0 per critical job |
the target or the whole job vanished |
a Watchdog / dead man's switch: vector(1) always firing, routed to an external service that pages when it stops arriving |
the alerting pipeline itself (Prometheus, Alertmanager, network) is broken |
PrometheusRuleFailures, PrometheusNotificationsDropped, AlertmanagerFailedToSendAlerts |
rules or notifications failing silently |
| scrape errors, TSDB compaction failures, high cardinality growth | the monitoring system's own health |
| certificate expiry, disk-full prediction | slow failures with a deadline |
kube-prometheus-stack ships the "Watchdog" alert and the Prometheus/Alertmanager self-monitoring rules from the kubernetes-mixin and prometheus-mixin projects; read them before writing your own.
Review alerts regularly
Once a month, list what paged and ask, for each: was it real, did someone act, could it have been a ticket? Delete or demote alerts that nobody acts on. Track pages per on-call shift; Google's SRE book suggests aiming for at most a couple of incidents per shift.
Test yourself
Which is the better page-level alert for linkly?
- CPU above 90% for 5 minutes
- 5xx ratio above 5% for 5 minutes
- A pod restarted
- Redis memory above 70%
What is a "Watchdog" alert for?
- Watching CPU
- It always fires; an external service pages when it stops arriving, proving the alerting pipeline works
- Silencing alerts
- Testing PromQL
"Disk will be full in 6 days" should be routed as…
- a page at night
- a ticket handled in working hours
- info only
- not alerted