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:
| Kind | What it is | Pila example |
|---|---|---|
| Logs | A line for each event worth recording, with a time | 07:41:02 number given: ticket 812, number 23 |
| Metrics | Numbers measured over time, cheap to keep and graph | Texts per minute; replies that failed; reply time |
| Traces | One request followed through every part it touches, with the time spent in each | A 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:
| Signal | Asks | Pila |
|---|---|---|
| Latency | How long do requests take? (Watch slow failures too.) | Seconds from a text arriving to the reply leaving |
| Traffic | How much demand is there? | Texts per minute |
| Errors | How many requests fail? | Texts that got no reply, or the wrong one |
| Saturation | How 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:
| Time | Traffic (texts/min) | Latency | Errors | Database connections |
|---|---|---|---|---|
| 7:00 | 12 | 0.3 s | 0.0% | 4 of 20 |
| 7:30 | 28 | 0.3 s | 0.1% | 11 of 20 |
| 7:52 | 41 | 0.3 s | 0.1% | 20 of 20 |
| 7:55 | 44 | 4.8 s | 0.4% | 20 of 20 |
| 8:00 | 46 | 11 s | 6.2% | 20 of 20 |
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
More than 2% of texts got no reply in the last 5 minutes, during opening hours
The server’s disk will be full in about 9 days at this rate
The server’s processor was at 85% for a minute
The SMS gateway is refusing every message
Texts arrived 30% faster than last Monday
The test certificate for staging expires in 20 days
Spot the trap: logging everything
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
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.
- Google SRE book, chapter 6: Monitoring Distributed Systems: the four golden signals, and what makes a good alert
- OpenTelemetry: Observability primer: logs, metrics and traces
- OWASP Cheat Sheet Series: Logging Cheat Sheet: what to log, and what never to
- Republic Act No. 10173, Data Privacy Act of 2012 (Lawphil): personal data in logs is still personal data