CD9: Monitoring, alerts and scaling

Lesson 4 of 5 · reading 15–25 minutes; practice and project time is on the module page

Alerts people trust

🎯You'll be able to

Write alert rules on user-facing symptoms with sensible waiting times, severities and runbooks, test them before they're used, and avoid alert fatigue.

🏠The everyday picture

A smoke alarm that goes off every time you make toast gets its battery taken out. Then it's silent on the day of a real fire. A good alarm reacts to real smoke, and the instructions for what to do are on the back.

📘What it really is

📝A worked example

Input: in the finished kit, run docker run --rm -v "$PWD/monitoring:/w" -w /w --entrypoint promtool prom/prometheus:v3.15.1 test rules alerts.test.yml. Then, with monitoring on, deploy the practice fault with terraform apply -var monitoring=true -var release_fault=errors and send traffic.

Expected output: promtool prints SUCCESS for the three test cases (10% errors fires the error alert, 1% doesn't, a stopped copy fires the copy-down alert after a minute). After the faulty release, Prometheus's Alerts page shows RouteRaniHighErrorRate as pending, then firing about a minute later, because the release fails about 25% of requests. Project 3 test 5 checks this happens within 150 seconds and that no alert fires under normal traffic. Apply again without the fault afterwards.

🌍Where it's used

📝Case scenario

A bank's operations team received about 300 alerts a night, mostly "CPU above 70%" on busy but healthy servers. A real database failure was buried among them and noticed by customers first. They deleted alerts that never led to action, alerted on payment errors and latency instead, added runbooks, and nights dropped to a handful of meaningful pages.

🖱️Try it

In alerts.test.yml, add a case where 4% of requests fail for 5 minutes and expect no RouteRaniHighErrorRate alert, then run promtool. Then change the expected result to an alert and run it again. Success: the first run passes and the second fails, so you've seen the tests catch a wrong expectation.

⚠️Common mistakes

🛠️For your project

Project 3 tests 1, 2 and 5 check the rules and their tests, that each alert has for, severity, summary and runbook, and that the error alert fires for a bad release and stays quiet otherwise.

✅Quick check

Why add for: 1m to an alert?

Show the answer

So the condition must last a minute before anyone is paged, ignoring blips.

What does promtool test rules check?

Show the answer

Which alerts fire, given made-up input series.

← PreviousDashboards that answer questions
ProLearners Assist