Expert · Monitoring and logging · topic 41 of 53 · 30 min
Alerting and on-call
Explanation
What an alert is for
An alert is an automatic message that asks a human to do something. A page is an urgent alert that rings a phone, even at 3 am. Because pages interrupt sleep and family time, each one has to earn its place. A good rule from Google's SRE practice: every page should be urgent, actionable, and about a problem users notice or will soon notice.
Symptoms, not causes
A symptom is what users feel: errors, slowness, a page that does not load. A cause is something inside: high CPU, one pod restarting, a full cache. Page on symptoms. CPU at 95% with users perfectly happy is not an emergency; a 10% checkout error rate with CPU at 30% is. Watch causes on dashboards and use them to debug.
| Kind | When | Example |
|---|---|---|
| Page (wake someone) | Users are hurt now and a human must act now | Checkout error rate above 5% for 10 minutes |
| Ticket (next working day) | Needs a human but can wait hours | Disk will be full in 4 days at the current rate |
| Dashboard or log only | Useful context, no action needed | One pod restarted and recovered |
Alert fatigue
Alert fatigue happens when people get so many alerts, mostly false or unimportant, that they stop paying attention. The phone buzzes twenty times a night, the engineer starts muting it, and the one real alert is missed. Every alert that fires without needing action is a bug in your alerting. Review pages every week and delete, tune or downgrade the noisy ones.
Thresholds and for durations
A threshold is the line that triggers the alert, such as "error rate above 5%". Real data is spiky, so a single bad minute should not page anyone. The for field in a Prometheus rule says how long the condition must stay true before the alert fires. A 5 to 15 minute for removes most flapping (an alert going on and off again and again). Choose thresholds from data: look at last month's graphs and from what users complained about.
Burn-rate alerts on SLOs (a preview)
Next module covers SLOs (targets like "99.9% of requests succeed over 30 days") and error budgets (the 0.1% you are allowed to fail). The burn rate is how fast you are using that budget: a burn rate of 1 uses it up exactly at the end of the window; a burn rate of 14.4 uses 2% of a 30-day budget in one hour. The Google SRE workbook suggests paging on fast burns over short windows (like 14.4 over 1 hour) and opening tickets for slow burns (like 1 over 3 days). This catches both sudden outages and slow leaks.
(
sum(rate(http_requests_total{job="checkout",status=~"5.."}[1h]))
/ sum(rate(http_requests_total{job="checkout"}[1h]))
) / (1 - 0.999) > 14.4Routing, grouping and escalation
Alertmanager decides who hears about each alert. It groups alerts that share labels (one message saying "30 pods are failing" instead of 30 messages), waits a little to collect related alerts, routes by labels (severity=page goes to the pager, the rest to chat), and supports silences during planned maintenance and inhibition (if the whole data centre is down, do not also send 500 alerts about each service in it).
route:
receiver: team-chat # default for everything
group_by: ["alertname", "service"]
group_wait: 30s # wait to collect related alerts
group_interval: 5m # gap between updates for a group
repeat_interval: 4h # remind if still firing
routes:
- matchers:
- severity="page"
receiver: oncall-pager
receivers:
- name: team-chat
slack_configs:
- api_url: "https://hooks.slack.com/services/REPLACE_ME"
channel: "#orders-alerts"
- name: oncall-pager
pagerduty_configs:
- routing_key: "REPLACE_WITH_INTEGRATION_KEY"Paging tools such as PagerDuty or Opsgenie hold the on-call schedule and the escalation policy: if the primary on-call does not acknowledge within, say, 15 minutes, the secondary is paged, and then the team lead.
Runbooks
A runbook (or playbook) is a short page linked from the alert that tells a sleepy engineer what to do. It should say: what the alert means, what users are feeling, which dashboard and logs to open, the first checks, safe ways to reduce the damage (roll back, turn off a feature flag, scale up), and whom to call if stuck. Put its link in the alert's runbook_url annotation.
Healthy on-call
- Share the rotation among enough people that nobody is on call most weeks, with a primary and a secondary.
- Google's SRE book suggests no more than about two incidents per 12-hour shift, so there is time to handle each one properly and follow up.
- Hand over at a fixed time with notes on what is still open.
- Give time off or pay for night pages, and fix the causes of repeated pages instead of accepting them.
Need help?
Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.
Try:
Watch the lesson
Alerting and on-call · 1/8
In this lesson you will learn how to write alerts that people trust, and how to keep on-call healthy.
Prefer a video by a teacher? Find free videos on “alerting best practices alertmanager on-call runbooks alert fatigue” on YouTube ↗
In real life: Cutting night pages at an e-commerce startup
The on-call engineers of a Jaipur e-commerce startup were paged about 60 times a week, mostly for "CPU above 80%" and "pod restarted". People had started sleeping through them. The team listed every page from the past month and asked, for each: did users feel it, and did anyone act? Only 7 passed. They replaced the rest with three symptom alerts (checkout error rate, checkout p95 latency, payment success rate), each with for: 10m and a runbook link, and moved disk and certificate warnings to tickets. Pages dropped to about 4 a week, and the next real outage was acknowledged in 2 minutes.
Practice (0/3 done)
The disk on a logging server will be full in about 5 days at the current rate. What should this alert be?
Write group_alerts(alerts, window) to cut noise. Each alert is a dict with "alertname", "service" and "time" (seconds). Sort alerts by time. Alerts with the same (alertname, service) are merged into one group while alert time minus the group's FIRST time is less than window. An alert outside the window starts a new group for that key. Return a list of (alertname, service, count) tuples in the order each group started.
Write a runbook for the alert OrdersHighErrorRate ("orders-api 5xx error rate above 5% for 10 minutes"). Keep it to one page that a half-asleep engineer can follow.
Quick quiz
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- SLIs, SLOs, SLAs and error budgetsSRE: reliability and incidents
- Capstone project: from commit to monitored productionGitOps, platform engineering and DevOps careers
- Monitoring, logs and alertsFull-Stack Development · Deploying and running the app
- Logging and monitoringBackend Development · Performance and reliability
- Privilege escalation concepts (labs only)Ethical Hacking and Penetration Testing (legal labs) · Deeper lab skills: passwords, privilege, Metasploit, wireless
- SIEM and alert triageCyber Security: from zero to SOC analyst · Logs, SIEM and incident response
Questions people ask about this
Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.
Which is the best page-worthy alert?
Answer: Checkout error rate above 5% for 10 minutes
It is a user-facing symptom, urgent, and needs action. The others are causes or can wait.
What is alert fatigue?
Answer: People ignoring alerts because there are too many noisy ones
Too many false or unimportant alerts train people to ignore them, so real ones are missed.
What does group_by: ["alertname", "service"] do in Alertmanager?
Answer: Sends related alerts with the same alertname and service as one notification
Grouping turns many similar alerts into one message.
What should a runbook contain?
Answer: What the alert means, first checks, safe mitigations and whom to escalate to
A runbook helps the on-call engineer act quickly and safely.
Why add for: 10m to an alert rule?
Answer: So a short spike does not page anyone; the condition must hold for 10 minutes
for prevents flapping alerts from brief spikes.
The observed error rate is 0.5% and the SLO is 99.9%. What is the burn rate?Related
Answer: 5
Burn rate = 0.5% / 0.1% = 5, so a 30-day budget would last only 6 days.
Why should an alert include a runbook_url?Related
Answer: The person paged can follow written first steps instead of guessing at 3 a.m.
A runbook link turns an alert into a clear next action.
An alert rule has for: 10m. What does that mean?Related
Answer: The condition must stay true for 10 minutes before the alert fires
Until for has passed the alert is pending; it fires only if the condition holds the whole time.
In an incident, what comes before finding the root cause?Related
Answer: Stopping the harm, for example by rolling back
First get users working again (rollback, restart, switch a feature off). Then find and fix the cause calmly.
Pass the quiz (60% or more) or mark this topic as done when you are ready.
Your progress is saved on this device only.
Next steps
- This is the last topic of “Monitoring and logging”. The module exam comes next.
- Module 9 exam: Monitoring and logging · 13 questions · 20 min, without help. 4 topics of this module still to finish first.
- Then the next module, SRE: reliability and incidents. 53 topics left in the course before the final exam.