Observability
Logs, metrics and traces as three questions, why percentiles beat averages, and a short checklist of what a service must tell you.
The fire alarm. It calls a human when the gauges look wrong.
That is the end goal of observability. A system running for real users has to tell you what is happening, without someone watching it all day, and it has to raise its hand when something is off.
How it works
Observability rests on three kinds of signal, each answering a different question.
- Logs: what happened? A line such as "payment failed for user 123". See logging.
- Metrics: how much, how often? Request count, error rate, latency, memory, database connections, cache hit ratio. See metrics.
- Traces: where did the request spend its time? See distributed tracing.
Request
↓
API gateway 10 ms
↓
Auth service 20 ms
↓
User service 50 ms
↓
Database 100 ms
Total: 180 ms
Alerts sit on top. They watch the metrics and wake a person when a threshold is crossed. An alert on uptime alone is not enough: a service can be up and returning errors, or up and taking ten seconds to answer.
Why percentiles beat averages
An average can hide slow requests.
99 requests at 50 ms
1 request at 10 seconds
The average looks healthy. The slowest request is unusable. Track P50, P95 and P99 latency, not only the mean. P99 is where a failing dependency shows up first.
A short checklist
- Structured logs on every service, with a request or correlation id on each line.
- Core metrics on a dashboard: requests per second, error rate and the latency percentiles.
- Alerts on error rate and latency thresholds, not only uptime.
- Tracing across service boundaries for anything beyond a single-service monolith.
- Error monitoring that groups repeated failures instead of listing each one.
Pick what you will act on
The aim is not to collect everything. It is to answer three questions quickly during an incident: is something wrong, where is it and what changed. Each signal that does not help answer one of those costs storage and attention. Start with the checklist above, then add a signal when a real incident showed you were missing it.
Errors and uptime
Error monitoring groups the same exception into one issue with a count, a first-seen time and the request that caused it. An uptime check from outside confirms that real users can reach the product at all, and a public status page tells them what you already know. Both are cheap, and both cover failures that internal metrics can miss.
Where I used it
I haven't shipped this in a public project yet, and I have no monitoring results to show.
What I can point to is a design note in POS SaaS. It says the age of the oldest pending invoice should be on a screen from the first day, because queue depth can be large and healthy while age cannot. That is a choice about which number to watch, written before any code ran. POS is early-stage, so it is a design and not an operating result.
Trade-offs
- Signals cost money and attention. Logs, metrics and traces all need storage and someone to read them. Cardinality, such as a metric labelled by user id, can make a bill grow quickly.
- Alert fatigue. Too many alerts teach people to ignore them. Each alert should mean someone has to do something.
- Instrument early, but not everywhere. Adding signals after an outage is too late. Adding every possible signal before launch is waste.
- Personal data in telemetry. Logs and traces can capture sensitive values. Redact before they leave the service.
- Averages lie. A dashboard of means will report a healthy system during a slow one. Use percentiles.
- A monolith needs less. With one service, logs and metrics usually carry you a long way before tracing is worth the effort.
A useful rule: for each alert, write down who is woken and what they do first. If you cannot, delete the alert.