How-To Guide

How to Choose Between Metrics, Logs, and Traces

Pick the right observability signal: metrics for trends and alerts, logs for detail, traces for causality, and use each for what it is good at.

On this page

  1. Introduction
  2. Start from the question you are asking
  3. Use metrics for trends and alerts
  4. Use logs for the specific detail
  5. Use traces for the causal path
  6. Let the signals work together
  7. Test that each signal carries its part
  8. Common pitfalls
  9. Conclusion

Introduction

Observability has three signals: metrics, logs, and traces. Each answers a different question and has a different cost, and using the wrong one for a question wastes effort and money. Metrics are cheap to aggregate over time and good for trends and alerts; logs are high-detail and good for the specific event; traces are structured and good for the causal path of one request. The skill is choosing the signal for the question instead of defaulting to one.

This tutorial covers starting from the question, using metrics for trends and alerts, logs for the detail, and traces for causality, and how they work together. The examples are the three signals, and the reasoning applies to any observability stack.

Start from the question you are asking

Each signal answers a kind of question. Is the service getting worse, or is it healthy? A metric answers that: a time series aggregated over a window. What exactly happened for this one request? A log answers that: the specific lines. Where did the time go across services? A trace answers that: the span tree. Deciding the question first points at the signal.

The common mistake is to default to one signal for everything. Logging a count lets you compute a trend, but expensively and noisily; encoding a specific error only as a metric loses the detail. Put each question to the signal that answers it cheaply and precisely, and let the signals complement each other.

Metrics are numeric series sampled over time, so they aggregate cheaply and answer is it getting worse over any window. They are the right signal for a dashboard trend and for an alert, because the monitoring system can compute the rate and the percentile from the stored series and evaluate a rule over a window. A metric is small and cheap to keep for a long time, which suits the trend view.

The cost of a metric is the cardinality: each label combination is a series, so the labels must be bounded. A metric cannot carry the detail of a specific event, and it should not try: a high-cardinality label for a user id or an order id explodes the series and overwhelms the backend. Keep the metric for the aggregate and put the detail in a log.

Use logs for the specific detail

A log line carries the detail of one event: the validation error, the payload that failed, the exception with its stack, the user and the order. It is the signal for what exactly happened, and it is where you look after a metric shows a problem. A structured log line, with named fields, is also queryable, so you can filter and aggregate a subset of the detail when you need to.

The cost of logs is the volume: logging everything is expensive to store and slow to search. Sample the repetitive high-volume lines and keep the errors and the interesting events in full. The log is the detail signal, so keep the detail that matters and drop the noise, and make each line structured so it is queryable rather than a string.

# a metric shows the error rate is up; the logs give the detail
jq -c 'select(.level == "error") | {msg, err: .err, orderId}' app.log | head
# the metric says how many; the logs say which error and for which order

Use traces for the causal path

A trace joins the operations of one request across services into a tree of spans, so it answers where the time went and what the request did. It is the signal for causality: a slow request names the span that dominated, and the spans across services show the hop. The trace is a structure, so it answers a question a metric and a log line cannot: the relationship between the operations.

The cost of traces is the volume of spans and the sampling decision. Tracing every request at full fidelity is expensive, so sample, and prefer a sampling that keeps the slow and error traces. A trace is high-cardinality by nature, with an id per request, which is why it is stored in a system built for traces rather than in a metric backend.

# a trace answers where the time went for one request
# GET /orders 2100ms
#   ├─ db.query orders    120ms
#   └─ GET reporting      1900ms   <- the slow hop, across a service boundary
# the metric said latency is up; the trace says it is the reporting call

Let the signals work together

The signals are most useful together, each answering its part of one investigation. A metric detects and alerts on the symptom; a trace, found by the request id from the alert, shows the causal path; a log, filtered by the same id, gives the specific detail at the failing span. The shared id joins the three, so the investigation moves from detect to explain in a few steps.

Share the context across the signals: the request id in the logs, the trace id in the trace, and the metric label by route, so a query on one finds the others. This is why a correlation id and a trace context are worth the plumbing: they connect the three signals into one investigation rather than three isolated tools.

Test that each signal carries its part

Test that the metric is emitted with the labels the dashboard and the alert use, and that its cardinality is bounded. Test that the log line is structured with the fields you query and the request id. Test that the trace propagates and records the spans across the boundary. Test that the shared id appears in all three, so an investigation can cross from one to another. These tests keep the signals usable together.

# one request id should appear in the metric's logs, the logs, and the trace
# assert the id is present in each signal for the same request, so they join

Common pitfalls

Logging a count and computing a trend from it expensively, encoding a specific error only as a metric so the detail is lost, an unbounded metric label that explodes the cardinality, tracing everything without sampling so the cost is high, and no shared id so the signals cannot be joined are the recurring mistakes. The question-first choice, a bounded metric, structured logs, sampled traces, and a shared correlation id address them.

Conclusion

Metrics, logs, and traces answer different questions. Start from the question, use metrics for trends and alerts, logs for the specific detail, and traces for the causal path, and join them with a shared id. Self-check by following one investigation from a metric to a trace to a log via the id, and by asserting each signal carries its part with bounded cardinality. Then each signal is used where it is cheap and precise.

Sources: OpenTelemetry: Signals, Google SRE: Monitoring distributed systems, Honeycomb: Observability and the three pillars.

FAQ

Which signal should I start with?
Metrics, because they are the cheapest to emit, aggregate, and alert on, and they answer whether there is a problem. From a metric that shows a problem, drill into the logs for the detail and the traces for the causal path. Metrics detect, logs and traces explain.
Can I replace logs with traces?
No. A trace shows the structure and the timing of the operations, but a log line carries the specific detail, such as a validation error, that a span's attributes may not include. Use traces for the where and the how long, and logs for the what.

Related Examples