Observability: logs, metrics, traces, alerts and SLOs
We'll cover the following
The three pillars
| Signal | What it is | What it tells you |
|---|---|---|
| Logs | One service diary of discrete events with text, for example "payment failed for order 7" | What happened inside one service |
| Metrics | Numbers over time: requests per second, error rate, p99 latency, CPU. Cheap and pre-aggregated. | That something is wrong. Used for dashboards and alerts. |
| Traces | The journey of one request across all services, with timing for each hop | Where it is slow |
Logs and traces are not the same thing: a log lives in one service, while a trace stitches the services together.
Correlation ID and distributed tracing
- A correlation ID (the transaction id every downstream call carries) is the foundation of tracing.
- Distributed tracing adds a trace ID for the whole request and a span for each hop (service A, then B, then the DB) with start time, duration and parent. They travel in headers (the W3C
traceparentstandard). - The waterfall view shows it at a glance: "checkout took 2.1 s, and 1.8 s of it was the inventory service".
- Tools: OpenTelemetry (the standard), Jaeger, Zipkin, Datadog.
- Generate the ID at your edge / gateway instead of trusting the client.
- Log the trace ID in every log line so logs and traces connect.
- Sample traces (for example 1% plus every slow or failed request), because tracing everything is expensive.
Alerting: symptoms, not causes
- CPU at 80% is a cause, and users may be perfectly happy at 80%. Alert on what users feel.
- The golden signals: latency, traffic, errors, saturation. For example "error rate above 1%" or "p99 checkout latency above 2 s".
- Autoscaling on resource metrics such as CPU or queue depth is a good use of them. It is not the same as paging a human.
- Only page a human for something actionable. Too many noisy alerts cause alert fatigue, and people start ignoring them.
SLI, SLO, SLA and the error budget
| Term | Meaning | Example |
|---|---|---|
| SLI (indicator) | A measurement | % of checkout requests that succeed in under 300 ms |
| SLO (objective) | Your internal target for the SLI | 99.9% over 30 days |
| SLA (agreement) | The customer contract, with penalties if missed. Looser than the SLO. | 99.5% or a service credit |
- Set the SLO stricter than the SLA, so you are warned well before you break the contract.
- Error budget: 99.9% allows 0.1% failure, about 43 minutes of downtime a month. A healthy budget means ship faster. A burned budget means freeze features and fix reliability.
- Burn-rate alerts: alert when you are using up the budget too fast. A fast burn (the month budget gone in 2 days) pages someone. A slow burn opens a ticket.
- Do not alert on the SLA directly.
Metrics vs logs, and the tools
- Normal way: the app emits metrics directly (counters, gauges, histograms) with Prometheus, StatsD or OpenTelemetry. Tiny numbers, cheap to store.
- Log-based metrics: a tool counts log lines that match a pattern ("ERROR lines per minute") in Splunk, Datadog or CloudWatch. It is a fallback for legacy apps you cannot change. It is fragile (a reworded message breaks the regex) and costly (logs are huge).
- Splunk started as a log search and analytics platform: it ingests and indexes machine data, you query it with SPL, and it has dashboards and alerts. It is heavy in ops and in security (SIEM), and now also offers metrics and tracing through Splunk Observability Cloud.
- Many companies use one platform for all three signals (Datadog, Grafana stack, New Relic, Elastic, Splunk). The storage underneath is separate, and the signals are linked by the trace ID.
- Open-source stack: ELK or Loki for logs, Prometheus + Grafana for metrics, Jaeger / Tempo for traces.
The 3am check
Check yourselfThe p99 checkout latency alert fires at 3am. In what order do you use metrics, traces and logs, and what does each one tell you?
Metrics first: what is wrong, which endpoint, since when, and how bad. Then traces: which service or hop is slow. Then the logs of that service at that time: why.
Summary: say it in the interview
- "Metrics for detection, traces for locating, logs for explaining. I alert on SLO burn and user-facing symptoms, not raw CPU."