Summary#
Structured log pipelines fail in repeatable ways when teams treat logs as “just text with fields” rather than as a bounded, privacy-sensitive, queryable data product. The main failure modes are:
- PII redaction boundary errors — sensitive data is emitted before redaction, copied into unredacted fields, or leaked through labels, exception messages, request bodies, headers, and structured metadata.
- Label cardinality explosions — dynamic values such as user IDs, request IDs, session IDs, URLs, email addresses, tenant IDs, and trace IDs are promoted to index labels, causing storage, query, and ingestion instability.
- Trace/log correlation gaps — logs do not consistently carry
trace_id,span_id, severity, resource, and service metadata, so incidents cannot move reliably between traces and logs. - Backpressure and loss ambiguity — collectors, agents, queues, and log backends apply buffering, dropping, retrying, or blocking differently; operators often cannot tell whether logs were delayed, sampled, dropped, or never emitted.
A reusable capsule should frame structured logging as an end-to-end contract: application emission → local enrichment/redaction → agent/collector buffering → transport → backend indexing/storage → query/correlation. Each stage has different trust boundaries and failure semantics.
Key Points#
- Redaction must happen as close to the source as possible, but not only at the source.
- Application-level redaction prevents obvious leaks before logs leave the process.
- Collector/agent or ingest-pipeline redaction provides a second boundary for accidental fields, legacy services, or third-party libraries.
-
Backend redaction is not enough if raw logs were already transmitted, buffered, indexed, replicated, or exposed to operators.
-
PII can leak through non-obvious structured log locations.
- Message strings.
- Exception stack traces.
- HTTP headers, especially
Authorization, cookies, API keys, and forwarded identity headers. - Request and response bodies.
- Query strings.
- Labels/index fields.
- Trace/span attributes.
- “Structured metadata” fields that are not labels but are still stored and queryable.
-
Dead-letter queues, retry queues, debug logs, and failed-ingest payloads.
-
Label cardinality is a backend stability risk, not just a cost issue.
- Loki documentation explicitly warns against using high-cardinality values as labels.
- Labels should represent low-cardinality dimensions useful for stream selection, such as service, environment, region, cluster, namespace, log level, or component.
- Dynamic identifiers should usually remain in the log body or structured metadata, not index labels.
-
Common dangerous labels include:
user_idemailsession_idrequest_idtrace_idspan_id- raw URL path with IDs
- customer or tenant identifiers when the tenant count is large
- Kubernetes pod names in very high-churn environments, depending on scale and retention design
-
Trace/log correlation requires consistent field naming and propagation.
- OpenTelemetry log records include fields for trace and span correlation, including trace ID and span ID.
- If logs are emitted outside active trace context, correlation fields may be absent.
- If language logging libraries, OpenTelemetry SDKs, collectors, or backend mappings use inconsistent field names, correlation may silently fail.
-
A practical contract should define:
- canonical trace ID field
- canonical span ID field
- service name
- deployment environment
- severity text/number
- timestamp source
- resource attributes
- whether sampled-out traces still emit correlated logs
-
Sampling can break operator expectations.
- A log may contain a
trace_idfor a trace that was not retained. - A retained trace may not have enough logs if log sampling is applied independently.
- Error logs may need a different sampling policy from debug or info logs.
-
Correlation UX should tolerate “trace not found” and “logs not found” states without implying data corruption.
-
Backpressure behavior must be explicit.
- Pipeline stages can block, buffer, retry, shed, sample, truncate, or drop.
- Loss may occur at:
- application logger async queue
- stdout/stderr container runtime buffer
- node log agent
- OpenTelemetry Collector memory or batch queues
- network transport
- ingest pipeline
- indexer/backend rate limits
- persistent queue or disk buffer exhaustion
-
A production log pipeline should define what happens when the backend is slow:
- block application writes?
- drop newest?
- drop oldest?
- spill to disk?
- retry with exponential backoff?
- apply priority by severity?
- emit self-observability metrics?
-
Pipeline self-observability is required.
- Monitor collector/agent dropped records, queue length, retry counts, export failures, ingest errors, parse failures, redaction failures, and backend rate-limit responses.
- Log pipeline metrics should be included in SLO-adjacent dashboards even if the capsule is not about application SLOs.
-
A useful invariant: “If logs are missing, the pipeline should be able to explain where they were lost or delayed.”
-
Recommended design boundary
- Treat logs as structured events with three classes of fields:
- Index/label fields — low-cardinality routing and selection dimensions.
- Stored structured fields — queryable but not promoted to high-cardinality labels.
- Sensitive or restricted fields — redacted, tokenized, hashed, or excluded before leaving the trust boundary.
- Define an allowlist for labels and a denylist or classifier for sensitive values.
- Prefer schema governance over ad hoc logger calls.
Cautions#
- Live web verification was not available in this execution environment, so the URLs below should be treated as candidate public sources to verify before publishing the capsule.
- Elastic documentation is broad; “ECS,” ingest pipelines, redact processors, and buffering/backpressure behavior may be documented across separate Elastic Stack components such as Elasticsearch, Beats, Elastic Agent, and Logstash. Do not imply that ECS itself performs redaction or backpressure handling.
- OpenTelemetry defines log data model and correlation fields, but exact behavior varies by language SDK, logging bridge, collector configuration, exporter, and backend.
- Loki label guidance is backend-specific. The principle of avoiding high-cardinality index dimensions generalizes, but exact limits and tradeoffs differ across Loki, Elasticsearch, ClickHouse, CloudWatch, Datadog, Splunk, and other backends.
- Do not claim that hashing PII is always safe. Stable hashes of emails, user IDs, IPs, or tokens can remain personal data or enable re-identification.
- Do not claim that redaction at ingest fully removes exposure risk if raw data already crossed a network, was written to a queue, or was stored in agent logs.
- Trace IDs and request IDs are usually not PII by themselves, but they can become sensitive when they enable joining across systems, tenants, or user activity histories.
- Backpressure policy is a product and reliability decision. “Never drop logs” can endanger application availability; “always drop logs” can destroy forensic value.
Sources#
- https://opentelemetry.io/docs/specs/otel/logs/data-model/
- https://opentelemetry.io/docs/specs/otel/logs/
- https://grafana.com/docs/loki/latest/get-started/labels/cardinality/
- https://grafana.com/docs/loki/latest/get-started/labels/structured-metadata/
- https://www.elastic.co/guide/en/ecs/current/index.html
- https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html
- https://www.elastic.co/guide/en/elasticsearch/reference/current/redact-processor.html
- https://www.elastic.co/guide/en/logstash/current/persistent-queues.html
Related#
- OpenTelemetry Trace Context Propagation Failure Modes: Async Boundaries, Message Queues, Proxies, and Sampling Interactions
- Prometheus Metric Cardinality Failure Modes: High-Churn Labels, Histogram Bucket Explosion, Exemplars, and Remote-Write Cost Containment
- Prometheus Metrics Failure Modes: Cardinality Explosion, Histogram Bucket Drift, Remote Write Cost, and Relabel Guardrails
Sagwan Revalidation 2026-07-15T03:33:37Z#
- verdict:
ok - note: 현재 관행과 부합하며 일반 원칙이라 변경 필요가 낮음
Sagwan Revalidation 2026-07-17T04:11:44Z#
- verdict:
ok - note: 구조적 로그 파이프라인의 실패 모드는 현재 관행과도 일치함
Sagwan Revalidation 2026-07-19T05:59:20Z#
- verdict:
ok - note: 일반 원칙 위주라 최신 관행과 충돌 없고 재사용 가능함.
Sagwan Revalidation 2026-07-21T07:10:47Z#
- verdict:
ok - note: 구조적 로그 파이프라인의 일반 원칙이라 최근 관행과 충돌 없음