Build Incident Timeline Dashboard from Logs and APM in Kubernetes

computer set
A step‑by‑step guide to create a unified incident timeline dashboard that merges structured logs and APM events in a Kubernetes environment.

Introduction

Kubernetes clusters generate massive amounts of telemetry: structured logs from each container, traces from APM agents, and metrics from the control plane. When an incident occurs, engineers often have to hop between log viewers, tracing tools, and metric dashboards, losing precious time. This guide walks you through a complete project that unifies logs and APM events into a single incident timeline dashboard. By the end you will have a reproducible pipeline, clear milestones, and a launch plan that can be adapted to any microservice stack.


1. Project Planning & Requirements

1.1 Define the Incident Use‑Case

  • Scenario: A sudden spike in HTTP 5xx responses triggers an alert.
  • Goal: Within 5 minutes, surface a timeline that shows the offending request, the associated log entries, and the trace spans that led to the failure.

1.2 Choose the Tech Stack

Component Recommended Choice
Log collector Fluent Bit (lightweight, native K8s integration)
Trace collector OpenTelemetry Collector
Time‑series store ClickHouse (fast columnar queries)
Visualization Lescopr Dashboard (built‑in timeline view)

1.3 Success Metrics

  • Mean Time to Resolve (MTTR) reduced by at least 30 %.
  • Query latency for timeline generation ≤ 2 seconds.
  • Storage cost under $0.10 per GB per month.

2. Data Ingestion Pipeline

2.1 Structured Log Export

  1. Deploy Fluent Bit as a DaemonSet.
  2. Configure a Kubernetes filter to add pod_name, namespace, and timestamp fields.
  3. Route logs to ClickHouse via the HTTP output plugin.

2.2 APM Event Export

  1. Instrument services with OpenTelemetry SDKs (Java, Node.js, Go).
  2. Export spans to the OpenTelemetry Collector.
  3. Use the ClickHouse exporter to store spans in a traces table that mirrors the log schema.

2.3 Normalizing Timestamps

Both logs and traces must share the same time source. Ensure all containers synchronize clocks via chrony and set TZ=UTC in pod specs. A small timestamp drift (≤ 5 ms) is acceptable; larger drift will break the timeline view.


3. Data Modeling for the Timeline

3.1 Unified Event Schema

CREATE TABLE events (
    event_id UUID,
    source Enum('log','trace'),
    timestamp DateTime64(3),
    pod_name String,
    namespace String,
    message String,
    trace_id UUID NULL,
    span_id UUID NULL,
    severity Enum('DEBUG','INFO','WARN','ERROR')
) ENGINE = MergeTree()
ORDER BY (timestamp, pod_name);
  • Logs populate source='log', message with the log line, and severity from the log level.
  • Traces populate source='trace', trace_id, span_id, and a generated message like "Span: HTTP GET /api/orders".

3.2 Merging Streams

A nightly materialized view combines the two raw tables into events:

CREATE MATERIALIZED VIEW mv_events TO events AS
SELECT * FROM logs UNION ALL SELECT * FROM traces;

4. Building the Dashboard

4.1 Dashboard Layout

  • Top bar: Alert banner with incident ID.
  • Timeline panel: Horizontal scroll showing events ordered by timestamp.
  • Detail pane: Clicking an event opens a modal with full log payload or trace span details.

4.2 Implementing the Timeline Component

  1. Query the events table for the last 30 minutes:
    SELECT * FROM events WHERE timestamp >= now() - INTERVAL 30 MINUTE ORDER BY timestamp ASC;
    
  2. In the frontend (React + D3), map each row to a node with color based on source and shape based on severity.
  3. Add zoom and brush interactions to focus on a specific time window.

4.3 Filtering & Aggregation

  • Provide checkboxes to hide DEBUG logs or non‑error spans.
  • Offer a group‑by option to collapse consecutive log lines from the same pod.

5. Testing & Validation

5.1 Synthetic Incident Generation

  • Use k6 to generate a burst of HTTP 5xx responses.
  • Verify that the timeline shows the request trace followed by the error logs within 2 seconds of query execution.

5.2 Performance Benchmarks

Test Avg Query Time Max Latency
5‑minute window 1.4 s 2.0 s
30‑minute window 1.9 s 2.5 s

If latency exceeds 2 seconds, consider adding a secondary index on namespace.


6. Deployment & Rollout

6.1 CI/CD Integration

  • Store pipeline definitions in a GitOps repo.
  • Use Argo CD to sync Fluent Bit, OpenTelemetry Collector, and ClickHouse manifests.
  • Add a Helm chart for the Lescopr dashboard component.

6.2 Monitoring the Dashboard Itself

  • Export dashboard latency metrics to Prometheus.
  • Set an alert when query time > 3 seconds for more than 5 minutes.

6.3 Documentation & Training

  • Create a run‑book that describes how to reproduce the timeline for a given incident ID.
  • Conduct a short workshop for SRE teams to practice navigating the view.

7. Post‑Launch Review

Collect feedback after the first month of production use. Measure the MTTR reduction against the baseline defined in Section 1.3. Iterate on filtering options and UI polish based on real‑world usage patterns.


Conclusion

By aligning structured logs and APM events into a single, searchable timeline, you give engineers the context they need to diagnose Kubernetes incidents quickly and reliably. The project outlined here provides a repeatable blueprint that can be adapted to any microservice architecture.

To go further, Lescopr's documentation covers step-by-step setup.