Releasing and running it · lesson 7 of 10
Ideas in this lesson
ALogs · metrics · traceswhat happened · how much, how fast · where the time went
BLatency · traffic · errors · saturationthe four golden signals
CAlerta message that wakes a person, because they must act

Monitoring and logs

Last updated

Once Pila is running, the team needs to know it's working before a patient has to tell them it isn't. Monitoring is how: the running system reports what it's doing, and the team watches a few numbers that matter. In this lesson you'll meet logs, metrics and traces, read a Monday-morning dashboard with Google's four golden signals, decide what deserves an alert at 7 a.m., and keep patients' details out of the logs.

By the end of this lesson you can

  • Tell logs, metrics and traces apart
  • Use the four golden signals to spot a problem
  • Choose alerts that matter, and keep personal data out of logs

Seeing inside a running system

A running system can tell you what it's doing, in three kinds of output:

Three kinds of telemetry
KindWhat it isPila example
LogsA line for each event worth recording, with a time07:41:02 number given: ticket 812, number 23
MetricsNumbers measured over time, cheap to keep and graphTexts per minute; replies that failed; reply time
TracesOne request followed through every part it touches, with the time spent in eachA text: gateway 40 ms → web server 10 ms → database 900 ms → reply

Monitoring is collecting these and watching them: graphs on a dashboard, and alerts when something crosses a line. The OpenTelemetry project, an open standard many tools share, calls the overall goal observability: being able to ask why the system is behaving as it is, from what it reports.

The four golden signals

Google's Site Reliability Engineering book says that if you can only watch four things about a service, watch these:

The four golden signals
SignalAsksPila
LatencyHow long do requests take? (Watch slow failures too.)Seconds from a text arriving to the reply leaving
TrafficHow much demand is there?Texts per minute
ErrorsHow many requests fail?Texts that got no reply, or the wrong one
SaturationHow full is the system? What runs out first?Database connections in use, of the 20 allowed

A busy Monday

Monday morning, the busiest time of the week. The dashboard, minute by minute:

Pila’s dashboard, Monday
TimeTraffic (texts/min)LatencyErrorsDatabase connections
7:00120.3 s0.0%4 of 20
7:30280.3 s0.1%11 of 20
7:52410.3 s0.1%20 of 20
7:55444.8 s0.4%20 of 20
8:004611 s6.2%20 of 20
Which signal showed the problem first?
What should the team’s first fix be?

Alerts that matter

An alert interrupts a person. Too many, and people learn to ignore them. Google's advice: alert on symptoms users feel, like errors and slow replies, not on every possible cause; and every alert should need a person to act, now.

0 of 6 placed right

  1. More than 2% of texts got no reply in the last 5 minutes, during opening hours

  2. The server’s disk will be full in about 9 days at this rate

  3. The server’s processor was at 85% for a minute

  4. The SMS gateway is refusing every message

  5. Texts arrived 30% faster than last Monday

  6. The test certificate for staging expires in 20 days

Spot the trap: logging everything

Spot the trapJun

Debugging a problem, Jun changes the log line to: number given to Remedios Cruz, 0917 123 4567, reason: prenatal check, number 23. “More detail makes debugging easier,” he says.

What happens if…

Check what you learned

Which kind of telemetry follows one request through every part of the system?
Which are the four golden signals?
What should an alert that wakes someone up be about?

Sources

Every claim on this page comes from these sources: the standard, the founding text of a method, a study, or the official record of a project, from the body that publishes it. Industry reports are labelled as such.

All sources for Simple Software Development