Lesson 3 of 9 · 26m
Log Pipelines, Retention, and Controlled Loss
Build resilient collection and routing pipelines that survive downstream failure, enforce retention, and make sampling or dropping an explicit operational decision.
A log pipeline is production infrastructure, not a side quest. When it fails silently, teams make confident decisions from partial evidence. I have seen an incident review declare an attack "small" because the dashboard showed few requests; the collector had dropped eighty percent of them. If telemetry is the evidence chain, the pipeline is the chain of custody.
Shape the pipeline deliberately
A typical pipeline has collection, enrichment, buffering, routing, indexing, and archive stages:
app stdout -> collector -> local buffer -> processors -> hot search store
+-> object storage archive
+-> security/SIEM streamFluent Bit, Vector, OpenTelemetry Collector, and Filebeat all implement variations of this shape. The exact tool matters less than knowing where loss can occur and where backpressure propagates.
Buffer before you ship
A collector that writes directly to a remote endpoint turns every downstream wobble into application risk. Use a disk queue when supported. A Vector-style configuration illustrates the intent:
[sources.app]
type = "docker"
[transforms.enrich]
type = "remap"
inputs = ["app"]
source = '''
.service = get_env_var("SERVICE_NAME") ?? "unknown"
.env = get_env_var("DEPLOY_ENV") ?? "unknown"
'''
[sinks.archive]
type = "aws_s3"
inputs = ["enrich"]
bucket = "prod-log-archive"
compression = "gzip"
encoding.codec = "json"
[sinks.archive.buffer]
type = "disk"
max_size = 268435456
when_full = "drop_newest"Read the when_full behavior literally. drop_newest, block, and overflow are different outage modes pretending to be one configuration key.
Do not let logging take the application down
In synchronous logging, the application waits for the log pipeline. That is convenient until the network partition arrives. Prefer asynchronous handoff, bounded queues, and local agents. If telemetry backpressure can stall checkout, you have built a distributed denial-of-service system against yourself.
Retention is an operational and legal decision
Different data deserves different lifetimes:
hot search: 7-30 days for incident investigation
security events: months or years when policy requires
archive: compressed object storage, lifecycle-tiered
debug noise: short retention or sampledWrite down who owns the decision. Security, compliance, cost, and incident response all have legitimate claims. "Keep everything forever" usually means "pay unpredictably and expose more data than necessary."
Measure the pipeline itself
Every serious pipeline emits metrics about itself:
sum(rate(vector_component_received_events_total[5m]))
sum(rate(vector_component_sent_events_total[5m]))
sum(rate(vector_component_discarded_events_total[5m]))Alert on sustained mismatch between received and sent volume, growing buffers, parse errors, authentication failures, and downstream 429s. A green application dashboard fed by a broken pipeline is worse than no dashboard because it manufactures confidence.
Field notes
- Clock skew corrupts investigations. Run NTP everywhere and include both event time and ingestion time when possible.
- Multi-line stack traces need parser rules. Otherwise one exception becomes hundreds of unrelated events.
- Test disaster behavior: restart collectors, fill disks, block network access, and watch what is lost.
- Version your parsing rules. A "small" rename can break dashboards, alerts, and audit queries simultaneously.
- Do not ship all debug logs forever because they helped once. Make debug activation temporary, targeted, and time-boxed.
Was this lesson helpful?