Skip to content
$ lynuxpro
← All system designs

MID · 12 MIN · SRE · DEVOPS · PLATFORM

Centralized logging pipeline

Agents on every node, a Kafka buffer, processing that redacts and routes, hot search for days and cheap archives for months.

Peak load
100 MB/s ingest
Availability target
99.9% (ingest)
RTO: back up within
1 hour (search)
RPO: data you can lose
< 1 min

← Swipe sideways to see the whole diagram →

ServiceInfrastructureQueue / streamData storeClientasync / background

The question

"Design a logging system that collects logs from thousands of containers, lets engineers search recent logs quickly, and keeps older logs cheaply."

Requirements

  • Collect stdout and log files from every pod and server.
  • Search the last 7-14 days in seconds; keep 1 year for audits.
  • Never lose logs during spikes or when the search cluster is slow.
  • Remove secrets and personal data before storing.

Quick numbers

ItemAssumptionResult
Ingest2 TB per day~25 MB/s average, ~100 MB/s peak
Hot storage14 days, 1 replica, compressed ~3x~19 TB
Archive1 year in S3, compressed ~8x~90 TB, cheap

How it works

  1. A Fluent Bit DaemonSet on each node tails container logs, adds Kubernetes labels (namespace, pod, app) and batches them.
  2. Batches go to Kafka, a buffer that absorbs spikes and lets the search cluster fall behind without losing data.
  3. Processors (Logstash, Vector or Fluentd) parse JSON, redact secrets and emails, drop debug noise, and route by team.
  4. Recent logs go to OpenSearch (hot, searchable). All logs also go to S3 in compressed files, queryable with Athena when needed.
  5. Index lifecycle policies roll indexes daily and delete them after 14 days.

Think of it like: a post office. Agents are the post boxes, Kafka is the sorting warehouse that never turns letters away, processors stamp and sort them, OpenSearch is the front desk for recent mail, and S3 is the long-term archive.

Key decisions

DecisionChoiceWhy
BufferKafkadecouples producers from storage; replays after failures
StructureJSON logs with standard fieldsfast, reliable search and dashboards
Hot vs cold14 days searchable, 1 year archivebalances speed and cost
Cheaper optionLoki instead of OpenSearchindexes labels only; much cheaper, slower full-text search

What breaks and how it heals

  • Search cluster down: Kafka keeps data (set retention to 1-3 days); consumers catch up after.
  • Log spike from a crash loop: per-namespace rate limits in the agent so one app can't flood everyone.
  • Agent falls behind: monitor its buffer and dropped-records metrics.

High availability and disaster recovery

TargetNumberHow it is met
Ingest availability99.9%agents buffer up to ~1-2 GB per node on disk if Kafka is unreachable
Kafka broker failsno lossreplication factor 3, min.insync.replicas=2, brokers in 3 AZs
Search cluster down for 3 daysno lossKafka keeps 72 hours of logs; processors catch up afterwards
Search cluster lostRTO ~1 hour3 dedicated master nodes, 1 replica per shard across AZs, hourly snapshots to S3
Data loss (RPO)under 1 minuteonly what sits in an agent's memory buffer on a node that dies
Audit archivecan't be deleted earlyS3 Object Lock (write once, read many) for 1 year

What interviewers listen for

  • A buffer between collection and storage, and back-pressure handling.
  • Hot/cold tiers with real cost numbers.
  • Redaction of secrets and PII, and per-tenant limits.