Stackbook Logo
observabilityestablished · high operational burden

Log Aggregation Pipeline

Also known as: centralized-logging, log-shipping-pipeline

Intent

Collect, buffer, process, and index logs from all hosts into a central store so they can be searched during incidents.

Problem

Logs scattered across ephemeral containers disappear when instances die and are impossible to search across services. Log bursts during incidents can also overwhelm the logging backend at the worst time.

Forces

  • •Ephemeral workloads lose local logs
  • •Log volume spikes during incidents
  • •Storage cost grows with retention
  • •Logs may contain sensitive data

Solution

Overview

A log aggregation pipeline moves logs from where they are produced to where they can be queried. Its main jobs are durability (logs outlive the instance), uniformity (common fields), and protection of the backend from bursts.

How it works

app stdout -> node agent -> broker (Kafka) -> processors -> hot index
                                                 |-> object storage (archive)
processors: parse JSON, join multi-line, add k8s labels,
            add trace_id, redact emails and tokens, sample debug

The agent tails container output and attaches metadata such as host, namespace, and pod. The broker decouples producers from the indexer: if the index is slow or down, logs queue instead of being lost. Processors normalize timestamps to UTC, enforce a schema, and tag each event with service name and environment. Tiered storage keeps recent logs fast to search and older logs cheap. Query access is audited, and field-level redaction happens before indexing, not after.

Operationally, track end-to-end lag, agent queue size, dropped events, and index rejection rate, and alert on them. Set per-service volume quotas so one noisy service cannot starve others.

Pitfalls

  • Treating logs as free. Indexing all fields of verbose logs can cost more than the compute that produced them.
  • Free-form text. Without structure, queries rely on fragile regexes; emit JSON.
  • Dropping logs silently on overflow. Make drops visible and prefer to shed low severity first.
  • Skipping redaction, which creates a compliance incident waiting to happen.

Key takeaways

  • Use an agent plus a durable buffer to survive bursts and restarts.
  • Normalize and enrich at the processing tier.
  • Tier retention to control cost.
  • Monitor the pipeline itself and redact before indexing.

✓ When to Use

  • •Fleets of containers or autoscaled instances
  • •Needing cross-service search and audit trails
  • •Compliance retention requirements

✗ When Not to Use

  • •Single small application where local files suffice
  • •Use as a metrics store, which is cheaper to serve as time series
  • •Unfiltered shipping of high-volume debug output

Pros

  • +Logs survive instance loss
  • +Central search across services
  • +Buffering absorbs bursts

Cons

  • −Storage and indexing cost can dominate
  • −Another pipeline to run and monitor
  • −Risk of leaking sensitive data into a wide-access store

Cost Profile

Infrastructure

High - storage, indexing, and brokers

Operational

High - capacity and schema management

Cognitive

Medium - many moving parts

Failure Modes

  • Agent falls behind and drops logs during an incident

  • Unparsed multi-line stack traces split into many events

  • Secrets or personal data indexed and widely readable

Real-World Examples

Alternatives

    Related Patterns

    • structured-logging
    • observability
    • distributed-tracing

    Competency Domains

    reliability ops