Skip to content

Expert · Monitoring and logging · topic 41 of 53 · 30 min

Alerting and on-call

Explanation

An alert should wake a person only when users are hurting, the person can do something about it, and it cannot wait until morning. Everything else becomes a ticket or a dashboard. Alertmanager and paging tools group, route and escalate alerts, and every alert needs a runbook that says what it means and what to check first. Too many noisy alerts cause alert fatigue, and then real problems are missed.

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.

KindWhenExample
Page (wake someone)Users are hurt now and a human must act nowCheckout error rate above 5% for 10 minutes
Ticket (next working day)Needs a human but can wait hoursDisk will be full in 4 days at the current rate
Dashboard or log onlyUseful context, no action neededOne 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.

output
(
  sum(rate(http_requests_total{job="checkout",status=~"5.."}[1h]))
    / sum(rate(http_requests_total{job="checkout"}[1h]))
) / (1 - 0.999) > 14.4
PromQL: page when the 1-hour error rate burns a 99.9% SLO budget 14.4 times faster than allowed.

Routing, 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).

yaml
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"
alertmanager.yml: group by alert and service, send pages to the paging tool and everything else to a chat channel. Keep real keys in a secret store, not in Git.

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.
Careful: Common mistakes: (1) Paging on causes like CPU instead of user symptoms. (2) No for duration, so alerts flap. (3) Alerts without a runbook, so each person guesses. (4) Sending every alert to everyone; route by service and severity. (5) Never deleting alerts; if nobody acted on it in a month, change or remove it.

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

Alerting and on-call

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)

Task 1 · Question

The disk on a logging server will be full in about 5 days at the current rate. What should this alert be?

Task 2 · Code · Python

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.

Task 3 · Practice

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

Question 1

1.Which is the best page-worthy alert?

Question 2

2.What is alert fatigue?

Question 3

3.What does group_by: ["alertname", "service"] do in Alertmanager?

Question 4

4.What should a runbook contain?

Question 5

5.Why add for: 10m to an alert rule?

Read more (free)

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.

From SLIs, SLOs, SLAs and error budgets

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.

From Capstone project: from commit to monitored production

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.

From Prometheus and Grafana

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.

From Monitoring, logs and alerts

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

  1. This is the last topic of “Monitoring and logging”. The module exam comes next.
  2. Module 9 exam: Monitoring and logging · 13 questions · 20 min, without help. 4 topics of this module still to finish first.
  3. Then the next module, SRE: reliability and incidents. 53 topics left in the course before the final exam.

← Previous: Logging: structured, safe and centralised