Skip to main content
Interactive otel-collector Configurator →Open Architecture Blueprint ↗
P1 INCIDENTL6 BARM11 · 5 MIN READ

OpenTelemetry Collector OOMKills & Prometheus Cardinality Explosions

Stop OTel Collector OOMKills and Prometheus TSDB memory blowups caused by unbounded user_id/request_id labels using memory_limiter, batch processors, and cardinality guards.

PRODUCTION SYMPTOM & ALERT SIGNATURE

Minutes after a new microservice ships, OpenTelemetry Collector pods enter CrashLoopBackOff (exit code 137 / OOMKilled) and Prometheus TSDB head_series jumps from 180k to 4.2M.

prometheus_tsdb_head_series > 1000000 OR increase(kube_pod_container_status_restarts_total{container="otel-collector"}[10m]) > 3
01 · ROOT-CAUSE MECHANICS (WHY IT HAPPENS)

Every unique label-value combination in Prometheus creates an independent in-memory time series in the TSDB head block (~3-5KB RAM per active series). Attaching unbounded labels like user_id, request_id, or raw URL paths with UUIDs multiplies series count by millions.

Inside the OpenTelemetry Collector, omitting memory_limiter (or placing it AFTER batch instead of FIRST in the processor pipeline) allows sudden telemetry bursts to exhaust container memory and trigger Linux OOMKiller before backpressure can shed load.

02 · LIVE TRIAGE COMMANDS (COPY & RUN)
Find the top metric names and label keys driving Prometheus cardinality
$ curl -s http://prometheus:9090/api/v1/status/tsdb | jq ".data.seriesCountByMetricName[:10], .data.labelValueCountByLabelName[:10]"
Smoking gun: One metric or label (e.g., path, user_id, trace_id) holding > 500k unique values.
Inspect OTel Collector memory_limiter drops vs process RSS
$ curl -s http://otel-collector:8888/metrics | grep -E "otelcol_processor_refused|otelcol_process_memory_rss"
Smoking gun: RSS climbing straight to cgroup limit with 0 refused spans (missing memory_limiter).
Verify OTel processor pipeline order in live config
$ grep -A 6 "processors:" /etc/otelcol/config.yaml
Smoking gun: memory_limiter MUST appear first, before transform/filter/batch.
03 · PRODUCTION DIFF (BROKEN VS HARDENED)
BROKEN · Broken Telemetry (raw UUID path label + no OTel memory_limiter)
# Prometheus metric with unbounded UUID in path label -> millions of series!
http_requests_total.labels(method="GET", path=request.url.path, user_id=user.id).inc()

# OTel Collector pipeline missing memory_limiter -> OOMKill exit 137
service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]   # DANGER: Unbounded RAM growth on burst!
      exporters: [otlp/tempo]
HARDENED · Bounded Cardinality + OTel Collector Backpressure Pipeline
# 1. Use low-cardinality route template (put user_id/request_id in traces & logs, NOT metric labels!)
http_requests_total.labels(method="GET", route="/v1/orders/:id", status_class="2xx").inc()

# 2. OTel Collector: memory_limiter MUST be FIRST, strip rogue labels via transform/attributes
processors:
  memory_limiter:
    check_interval: 1s
    limit_percentage: 75
    spike_limit_percentage: 20
  attributes/drop_high_card:
    actions:
      - key: user_id
        action: delete
  batch:
    send_batch_size: 4096
    timeout: 2s
service:
  pipelines:
    metrics:
      receivers: [otlp]
      processors: [memory_limiter, attributes/drop_high_card, batch]
      exporters: [prometheusremotewrite]
04 · MINUTE-24 BAR-RAISER CHECKPOINT (L6 · M11)TEST YOUR INSTINCT · ZERO SIGNUP

An engineer adds user_id and full URL path (/orders/9f2a...) as Prometheus metric labels to debug a checkout issue. Prometheus OOMs 12 minutes later. What is the right observability boundary?

05 · POST-FIX VERIFICATION CHECKLIST
  • Confirm memory_limiter is the FIRST processor in every OTel Collector pipeline (traces, metrics, logs).
  • Enforce metric_relabel_configs (or OTel transform processor) to drop unbounded labels and normalize route templates.
  • Set Prometheus --storage.tsdb.max-block-chunk-segment-size and per-scrape sample_limit so one rogue service cannot OOM the entire monitoring cluster.
06 · FREQUENTLY ASKED ENGINEERING QUESTIONS

Why must memory_limiter be the first processor in an OpenTelemetry Collector pipeline?

So the collector refuses incoming batches at the receiver boundary before downstream transform or batch processors allocate large buffers and trigger a Linux OOMKill.

How do I correlate a Prometheus p99 spike to a specific user without adding user_id as a label?

Enable OpenTelemetry Exemplars on histogram metrics: each histogram bucket attaches a sampled trace_id that jumps straight to the full high-cardinality trace.

What is a safe Prometheus sample_limit per scrape target?

Set sample_limit (e.g., 10000 to 50000 depending on service size) in scrape_configs so a single accidental cardinality bug fails that target’s scrape instead of crashing Prometheus globally.