awesome-everything RU
↑ Back to the climb

Observability

Logs and volume: the cost model of structured logging

Crux How structured logs work, why ingestion bytes dominate the bill, and how level discipline and tiered retention control the cost.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at middle altitude — in the sky
◷ 12 min

A team’s logging bill quadrupled in two months while traffic is flat. One refactor quietly changed a retry count from 3 to 20 — and with it, an INFO log line emitted per attempt. Sixty GB per day became 600 GB per day from one service.

What a structured log is

A log line is an event record: a timestamp plus a payload that describes what happened. Production observability in 2026 is structured-or-nothing: a JSON event with consistent keys is the only form that supports filter-aggregate queries at scale.

Mandatory fields per log line:

  • timestamp (ISO-8601 UTC)
  • level (debug / info / warn / error)
  • service.name
  • trace_id (the join key to traces)
  • span_id
  • message
  • Plus event-specific fields (user_id, order_id, status_code, etc.)

The join key trace_id is what makes it possible to navigate from a metric spike to a log line to a trace with a single click. Without it, you have three disconnected dashboards and no narrative.

The storage model

The pipeline is append-only ingest with indexed search:

  1. Application emits JSON to stdout or a local agent (Fluent Bit, Vector, OTel Collector).
  2. Agent buffers and ships to a log backend (Loki, ClickHouse, Elasticsearch, Datadog, Splunk).
  3. Backend indexes a subset of fields for fast filtering; stores the rest for raw scan.

Logs preserve everything you wrote — high cardinality is free at write time but expensive at query time, since the backend must scan or index every field. Unlike metrics, there is no cardinality explosion from adding user_id to a log line; the cost is paid in ingestion bytes and query scan time, not in series-count memory.

Log levelMeaningProduction default
debugVerbose trace of internal stateOff
infoState-change events (request completed, order created)On, but sample high-volume paths at 1%
warnRecoverable failure (retry succeeded after N attempts)100%
errorUnrecoverable, actionable failure100%

Ingestion volume: the cost math

A modest service at 1 000 req/s emitting 1 KB of structured JSON per request produces:

  • 1 MB/s = 86 GB/day = 2.6 TB/month per service

Multiply by 50 services in a typical fleet and the bill at $0.10/GB ingest plus indexed-event cost reaches tens of thousands per month before retention costs.

Standard cost-control patterns:

  1. Log-level discipline. DEBUG off in production. INFO for state-change events only. WARN for recoverable failures. ERROR for actionable failures.
  2. Sampling on success paths. 1-in-100 for high-volume successful INFO events; 100% for errors and warns.
  3. Tiered retention. 15-day hot for queries; archive to cheap object storage for compliance. Most log queries happen in the first 3 days.
  4. Redirect chatty tiers. Datadog Flex Logs and Splunk tiered indexes let you route high-volume/low-value events out of the expensive indexed tier into a cheaper scan tier.
Why this works

The retry-log antipattern is the most common cause of surprise log bills: a refactor raises retries from 3 to 20, each attempt emits an INFO line, and the service that was responsible for 5 GB/day suddenly produces 60 GB/day. The fix is to emit a single structured log at the end of the retry sequence — {attempts: 20, final_outcome: "timeout"} — instead of one line per attempt. A metric counter payment_retries_total{outcome} captures the volume cheaply.

Order the steps

A logging bill quadrupled while traffic is flat. Order the diagnosis steps:

  1. 1 Open vendor dashboard — find ingest GB/day per service
  2. 2 Identify the service whose volume jumped (e.g., from 5 GB/day to 60 GB/day)
  3. 3 Aggregate log volume by log_pattern inside that service
  4. 4 Find the chatty log line (e.g., one per retry attempt)
  5. 5 Assess the correct log level (retry attempt = DEBUG or one WARN on final failure)
  6. 6 Apply short-term mitigation: route to sampled tier or raise level to WARN
  7. 7 Durable fix: emit one summary log at end of retry sequence + add a metric counter
Quiz

A service emits an INFO log line for every retry attempt. After a refactor raises retries from 3 to 20, the logging bill 4x in two months. What is the durable fix?

Quiz

Why does adding user_id to a log line not cause the same explosion as adding it as a metric label?

Log volume cost numbers
Typical log volume per service at 1k req/s with 1 KB per request
~86 GB / day
Datadog log ingest
~$0.10 / GB
Datadog indexed log events
~$1.27 / million
Hot retention typical (query tier)
15 days
Recommended success-path log sampling
1% INFO, 100% WARN+ERROR
Retry-antipattern volume multiplier (3→20 retries)
~6-7x bill increase
Recall before you leave
  1. 01
    What are the mandatory fields in a production-quality structured log line, and why is trace_id particularly important?
  2. 02
    A service produces 86 GB/day of logs. Name three controls to reduce this without losing actionable data.
  3. 03
    Why is structured (JSON) logging required for filter-aggregate queries at scale, while plaintext is not?
Recap

A structured log is a timestamped JSON event with consistent keys; it is the only form that supports filter-aggregate queries at production scale. The backend pipeline is append-only ingest with indexed search, storing every field you write. Unlike metrics, logs have no cardinality explosion from high-cardinality fields — but they pay in ingestion bytes: 86 GB/day per service is typical at 1 000 req/s. Level discipline (DEBUG off, INFO sampled, WARN/ERROR 100%) and tiered retention control the bill. The mandatory trace_id field is the join key that connects log lines to traces, enabling single-click pivots from a log search to a full span waterfall in the tracing backend.

Connected lessons
appears again in167
Continue the climb ↑Traces and sampling: the cost model of distributed tracing
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.