पाठ 22 / 35
Connecting Logs, Metrics and Traces
यह पाठ अभी हिंदी में अनुवादित नहीं है, इसलिए अंग्रेज़ी में दिखाया जा रहा है।
Link the three signals with trace IDs and exemplars so you can jump from an alert to the exact failing request.
लेखक: Rahul Agarwal · 15 साल से वेब डेवलपर
Pivoting between signals
Each signal is useful alone, but debugging speed comes from moving between them without retyping filters.
Logs to traces: inject the active trace_id and span_id into every log line. OpenTelemetry's logging integrations and many logging libraries can do this automatically. In the log UI, the trace ID becomes a link that opens the full trace.
Metrics to traces: an exemplar is a sample trace ID attached to a metric observation, for example to the histogram bucket that recorded a slow request. When a latency graph spikes, the UI can show dots for exemplars; clicking one opens a real request from that spike. Prometheus and OpenMetrics support exemplars, though they must be enabled.
Traces to logs and metrics: the trace's resource attributes (service.name, k8s.pod.name) and time range let the UI build a log query for that pod at that moment.
All of this only works if names agree. Use the same service.name in every signal, and the same label values (env, region) across logs, metrics and traces.
Shared identifiers in practice
A log line carrying the trace and span IDs, and a histogram bucket sample carrying an exemplar that points at the same trace.
{"ts":"2026-03-14T06:12:09.418Z","level":"ERROR","service":"payment-service",
"msg":"charge failed","order_id":"A17","error":"upstream timeout",
"trace_id":"4bf92f3577b34da6a3ce929d0e0e4736","span_id":"b7ad6b7169203331"}
# OpenMetrics exemplar: a sample bucket observation linked to the trace that produced it
http_request_duration_seconds_bucket{le="0.5",route="/checkout"} 905 # {trace_id="4bf92f3577b34da6a3ce929d0e0e4736"} 0.43One PNR, every system
Your PNR number works at the booking site, the station enquiry counter and the TTE's chart. Because everyone uses the same key, you can move from "my booking" to "my seat" to "my refund" instantly. A trace ID is that PNR for a request across logs, metrics and traces.
त्वरित जाँच: What is an exemplar?
- A trace ID attached to a metric sample, linking an aggregate to a concrete request
- A dashboard template
- A log line that has been sampled
- A synthetic test request
Answer
A trace ID attached to a metric sample, linking an aggregate to a concrete request — Exemplars bridge metrics and traces: a metric observation carries the ID of a trace that contributed to it, so you can open an example request from a graph.