Q&A-2Compare metrics, logs, and traces for incident investigation.
Answer
What a strong candidate says first
Metrics are pre-aggregated numbers on a fixed interval: they answer how bad, how wide, since when, and they are the only signal cheap enough to alert on. Traces are causal span trees: they answer which hop in the call graph burned the time. Logs are per-event records: they answer what exactly happened on this one request. The investigation order follows the cost: alert on a metric, pull a representative trace, read the logs for that trace ID.
The comparison
| Metrics | Traces | Logs | |
|---|---|---|---|
| Answers | scope, rate, saturation, SLO burn | which hop, queue vs compute | exact error, payload, ordering |
| Cost driver | active series × samples | spans/s × span size | bytes/s |
| Typical defaults | Prometheus scrape_interval 1m (shipped example config 15s), local TSDB retention 15d, 5m lookback | OTel SDK default sampler parentbased_always_on; Jaeger default remote strategy probabilistic 0.001; Collector tail_sampling decision_wait 30s | Loki retention_period 744h (31d); Elasticsearch guidance 10–50 GB per shard |
| Fails by | cardinality explosion | broken context propagation, head sampling | volume, no correlation key |
Where the numbers bite
Cardinality: one metric name, http_requests_total{method,path,status,instance}, with 5 methods × 200 paths × 10 statuses × 50 instances is 500,000 active series. Single-node Prometheus is sized in the low millions of active series; one instrumentation line just spent a quarter of it.
Sampling: 5,000 rps × 50 spans per trace = 250,000 spans/s. At 1% head sampling that is 2,500 spans/s; at roughly 1 KB per span, 2.5 MB/s ≈ 216 GB/day. Head sampling at 1% also drops 99% of the slow requests you are investigating: use tail sampling with an error/latency policy, or accept that the trace you need may not exist.
Log volume: 5,000 rps × 200 B per line = 1 MB/s ≈ 86 GB/day, before replication. Keep errors at 100%, sample debug.
Worked trace (hypothetical figures)
14:02. Alert: checkout-api p99 of http_request_duration_seconds (default buckets include 1 and 2.5) goes 180 ms → 1.4 s. An exemplar on the slow bucket carries a trace ID (Prometheus 2.26+).
The trace shows 1.35 s of the 1.4 s inside one postgres.query span on orders-db; the parent charge_card span is 40 ms. The time is in the database call, not the payment provider.
Logs filtered by that trace ID, 14:01:58: pq: sorry, too many clients already. Pool max is 20, 60 concurrent checkouts. Root cause is pool exhaustion, not slow queries.
Detection that would have fired earlier: alert on pool wait time or pg_stat_activity count, not on request latency.
Failure modes and what the trio misses
- Metrics cannot tell you which of 50 pods is bad unless you label by pod, and pod × path is exactly the cardinality explosion above.
- Traces need
traceparent(W3C Trace Context: 128-bit trace ID, 64-bit span ID) propagated through every hop; one service that drops the header splits one trace into several and the causal path is gone. - Logs without a trace ID are a grep exercise; clock skew across hosts reorders them.
- None of the three shows CPU burn inside a process: that is continuous profiling (pprof), the fourth signal you reach for when the trace says "this span is slow" but not why.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.