BOOKS DEEP-READ · SRE · CH 10

Practical Alerting from Time-Series Data

Site Reliability Engineering · Ch 10 · Google · 2016

中文 →

What is this chapter about?

The reason you can order something at 2am and it just works is that someone is on call — phone on the nightstand, ready to get up and fix things. This chapter isn't about the fixing. It's about when that phone should ring at all: how Google turns the numbers scattered across hundreds of thousands of machines into a single judgement, "somebody has to act, now."

A strange thing first

You probably assume the hard part of monitoring is noticing problems. In practice the hard part is not crying wolf. An alarm that has gone off a hundred times and meant nothing ninety-nine of them has already taught the on-call engineer to ignore it — that's not laziness, that's how people respond to false alarms. So the real question of this chapter is: how do you make the phone ring less, without missing the real thing?

Why the old world was hard

Early monitoring worked like bolting a smoke detector onto every machine: ask each one in turn "is your CPU high? is your disk full?" and let whoever crosses a line shout. That's fine for a few dozen machines and awful past a few thousand. A routine rolling restart sets off hundreds of detectors at once while no user notices anything; meanwhile the failures that actually hurt often look fine machine by machine — one percent of requests failing on each box adds up to a great many people staring at an error page. Worse, a detector like that can only say "over the line right now". You can't ask it what the number was last Tuesday at this hour, or how long this trend has before it hits the wall.

How it actually works

The idea is to flip it: machines don't judge themselves, they just report numbers.

Every program keeps a little chalkboard by its front door: how many requests I've handled in total, how many of those failed, how many people are queued up right now. The monitoring system walks the neighbourhood every ten seconds and copies the boards down. What it collects is not "good" or "bad" — it's numbers over time, like a temperature chart rather than the sentence "he's sick".

Each copied line carries a few tags: which service, which datacenter, which machine. So "should we call someone" becomes arithmetic on those lines: add up the thousands of machines belonging to one service (stop looking at them one by one), turn it into a proportion (what fraction of requests failed, so the rule works whether you run three machines or three thousand), and finally require it to stay over the line for five minutes — anything that twitches once and heals itself was never worth a phone call.

The lovely part is that one set of copied numbers serves three jobs at once: it fires the page, it draws the dashboards, and during an investigation it lets you go back and ask what yesterday looked like. And the judgement has moved from "which machine feels unwell" to "are users actually being hurt".

What it costs

Copying numbers is so cheap that everyone copies everything, and a few years later there are more charts than anyone can account for — storing them, and finding the one that matters, becomes its own problem.

Remember one thing

Good alerting isn't about picking the right threshold. It's about recording the world as curves you can do arithmetic on, and then making "should we wake someone" an expression over those curves — an expression can be reviewed, changed and reused. Ten thousand thresholds scattered across ten thousand machines cannot.

Want /varz instrumentation, labelled time series, the rate-and-ratio rule algebra and the diagrams? → switch to the deep read