The OTel Collector and Telemetry Pipelines
The OpenTelemetry part ended with data leaving the SDK as OTLP. This part is what receives it. The Collector is the physical implementation of the middle of the seven-step pipeline from the Telemetry pipeline part (collect → process), and it is the practical answer to "where do we decide what to throw away": not in 200 services' code, but in one deployable layer. The trace-only view (head vs tail sampling, the loadbalancing exporter in depth, queue metrics to watch) is in the Distributed Tracing guide; this part covers all three signals and the topology.
The Pipeline Model
A pipeline is a chain receivers → processors → exporters for exactly one signal type (traces, metrics or logs). You define each component once in its own top-level block, then wire them in service.pipelines. A component that is configured but not referenced in a pipeline is silently inactive.
| Component | What it does | Examples |
|---|---|---|
| Receiver | Gets data in: either listens (push) or goes and fetches (pull). Translates it into the Collector's internal pdata form. | otlp, prometheus, filelog, hostmetrics, kubeletstats, jaeger, kafka |
| Processor | Transforms, enriches, filters or batches data in flight. They run in list order. | memory_limiter, batch, k8sattributes, resource, attributes, filter, transform, tail_sampling |
| Exporter | Sends data out, with its own retry and queue. | otlp, otlphttp, prometheusremotewrite, loadbalancing, debug |
| Connector | Is an exporter in one pipeline and a receiver in another, optionally changing the signal type. Referenced in both lists. | spanmetrics (traces → metrics), servicegraph (traces → metrics), count (any → metrics), routing, forward |
| Extension | Not in the data path. Adds capabilities to the process itself. | health_check (liveness/readiness), pprof (Go profiling), zpages (live in-process debug pages), file_storage (disk for persistent queues and receiver checkpoints) |
Distributions: Core, Contrib, K8s, Custom
A distribution is a pre-built Collector binary containing a fixed set of components. The project publishes several, and none is "the" Collector:
| Distribution | Contains | Use it for |
|---|---|---|
otelcol (core) | OTLP, a few basic processors and exporters, the core extensions | Minimal base; rarely enough on its own (no k8sattributes, no filelog, no prometheusremotewrite) |
otelcol-contrib | Everything in the contrib repo: hundreds of receivers, processors, exporters | Prototyping. In production it is a large attack surface and a larger binary for components you do not use |
otelcol-k8s | A curated subset for Kubernetes node and cluster collection | Agent/gateway on Kubernetes without custom builds |
| Custom, built with ocb (OpenTelemetry Collector Builder) | Exactly the components in a manifest you write | Production: small binary, auditable dependencies, one vulnerability surface you control |
dist: { name: otelcol-acme, output_path: ./build }
receivers:
- gomod: go.opentelemetry.io/collector/receiver/otlpreceiver v0.163.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver v0.163.0
processors:
- gomod: go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.163.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor v0.163.0
exporters:
- gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.163.0
connectors:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector v0.163.0Most of the Collector is still on v0.x (the latest release as of this writing is v0.163.x, October 2026) with a new minor every couple of weeks. Component configs can and do change between minors, and each component has its own stability level (alpha/beta/stable) per signal, so pin versions and read the changelog before bumping. Do not assume that "the Collector is stable because OTLP is".
The Processors That Matter, and Their Order
Processors run in list order, so the order is a program, not a set. The practical recommendation:
memory_limiterfirst. It samples process memory everycheck_intervaland, past a soft limit (limit − spike_limit), starts refusing new data by returning an error to the previous component; past the hard limit it forces a GC. The docs say to put it first so that component is the receiver, which can push back on its sender instead of accepting data it cannot hold. Setcheck_interval: 1s(the default is 0, i.e. unset) and make the limit about 80% of the container memory limit, withlimit_percentage/spike_limit_percentagereading cgroup limits automatically on Linux.spike_limit_mibdefaults to 20% of the limit.Enrich next:
k8sattributes,resourcedetection,resource.k8sattributeslooks up the pod from the incoming connection and addsk8s.namespace.name,k8s.pod.name, deployment, node, and (optionally) selected pod labels. It needs RBAC to list and watch pods, namespaces and nodes.resourcedetectionaddscloud.*,host.*from the environment.resourceandattributesset, rename or delete fixed attributes.Cut:
filterthentransform.filterdrops whole telemetry matching an OTTL condition (health-check spans, DEBUG logs, noisy metrics). OTTL (OpenTelemetry Transformation Language) is a small expression language used byfilter,transformand some connectors:delete_key(attributes, "user.id"),set(attributes["env"], resource.attributes["deployment.environment.name"]). Usetransformto normalize semconv generations, drop high-cardinality attributes and redact. Filtering before heavy work saves CPU for everything after it.tail_samplinglate, beforebatch, and only on the tier that has whole traces (see topology below, and the Distributed Tracing guide).Batching last. Batching after drops means you only batch what survived.
Batching: Processor or Exporter?
Batching amortizes per-request overhead (TLS, headers, compression, protobuf framing) over thousands of items; a request per span would be hopeless. There are now two ways to do it, and this is the part of Collector guidance that has changed recently:
batch processor (the long-standing way)
A pipeline stage with send_batch_size: 8192 (a trigger, not a cap), timeout: 200ms and send_batch_max_size: 0 (no upper limit unless set). It is still documented as beta for all three signals. Caveat: it buffers items in memory and acknowledges the upstream immediately, so a crash loses what it holds and a downstream failure shows up only as a log line, not as an error the receiver can pass back to the client. It sits before the exporter's queue, so batching and persistence are two separate things.
Exporter-side batching (newer)
Batching configured inside the exporter's sending_queue as a batch: block: flush_timeout (default 200ms), min_size (default 8192), max_size, with a sizer in items or bytes. It is off by default; batch: {} turns it on. It batches after the queue, which means it composes with a persistent queue and lets the queue carry backpressure to receivers. Check the stability and defaults for your version before depending on it.
Both are in the tree and neither is removed; the pragmatic reading is that the processor is the compatible default with the loss-on-crash trade-off, and exporter-side batching is where the project is moving for pipelines that need durable queues and honest backpressure. The tracing guide's examples use the processor; they are not wrong.
Receivers Worth Knowing
| Receiver | Mechanism | Gotcha |
|---|---|---|
otlp | Listens on 4317 (gRPC) and 4318 (HTTP). The default entry point for everything SDK-based. | Binds localhost by default in recent versions; set 0.0.0.0:4317 explicitly in a container or nothing outside can reach it. |
prometheus | Embeds the Prometheus scrape engine: the same scrape_configs, service discovery and relabeling (see Prometheus), converting results to OTLP metrics. | Every $ in a scrape config must be escaped as $$ (the Collector expands env vars first). A DaemonSet with the same config on every node would scrape every target N times; use the Target Allocator to shard targets across Collectors. |
filelog | Tails files (/var/log/pods/*/*/*.log), parses with operators (container format, JSON, regex), tracks offsets. | Offsets are in memory unless you give it a storage: file_storage; a restart without that either re-reads or skips lines. Exclude the Collector's own log file or it ingests its own output in a loop. |
hostmetrics | Reads CPU, memory, disk, filesystem, network from /proc, /sys on the host. Agent-only. | In a container, mount the host filesystem and set root_path, or you report the container's numbers. |
kubeletstats | Queries each node's kubelet /stats/summary for pod and container CPU, memory, volume, network. | One per node (agent); auth via service account. |
Deployment Topology: Agent and Gateway
An agent is a Collector running next to the workload: a DaemonSet (one per node) or a sidecar (one per pod). A gateway is a Collector deployed as a central, horizontally scaled service (a Deployment behind a Service or load balancer). You usually want both, because they are good at different things:
| Agent (DaemonSet / sidecar) | Gateway (Deployment) | |
|---|---|---|
| Only place that can | Read node-local things: log files, hostmetrics, kubeletstats; see the real pod IP of the sender for k8sattributes; accept OTLP on localhost so the app never leaves the node | Make cluster-wide decisions: tail sampling, global rate limits, central credentials to backends, one egress point |
| Cost | N copies of a Collector: small CPU and memory reservation per node, multiplied by node count (sidecars: per pod, worse) | Extra network hop and one more tier to run, scale and upgrade |
| Failure scope | One node's telemetry | Whole cluster, if undersized or a single replica |
The reason for the two-tier shape is that tail sampling decides whether to keep a trace after seeing all of it ("keep every trace with an error or over 1 s, plus 5% of the rest"). That is only possible if every span of one trace reaches the same Collector process. Spans of one trace arrive from many services and nodes, so a plain load balancer in front of gateway replicas would scatter them and every replica would make decisions on fragments. The loadbalancing exporter in tier 1 solves that by hashing the routing key (traceID for traces) over a set of tier-2 backends, discovered with a dns (headless Service), k8s (EndpointSlice watch; needs RBAC) or static resolver. At the time of checking, loadbalancing is beta for traces and logs and alpha for metrics. Trace-level mechanics, including what happens to in-flight traces when tier 2 rescales, are in the Distributed Tracing guide.
A Real Config: Agent → Gateway → Tier 2
Agent (one per node). Its job: take OTLP from local pods, add node-local data, enrich, then forward over OTLP with a durable queue.
otel-agent.yaml
extensions:
health_check: { endpoint: 0.0.0.0:13133 }
file_storage:
directory: /var/lib/otelcol/queue
create_directory: true
compaction: { on_rebound: true, directory: /tmp } # bbolt never shrinks on its own
receivers:
otlp:
protocols:
grpc: { endpoint: 0.0.0.0:4317 }
http: { endpoint: 0.0.0.0:4318 }
hostmetrics:
collection_interval: 30s
scrapers: { cpu: {}, memory: {}, filesystem: {}, network: {}, load: {} }
kubeletstats:
auth_type: serviceAccount
endpoint: ${env:K8S_NODE_NAME}:10250
collection_interval: 30s
filelog:
include: [ /var/log/pods/*/*/*.log ]
exclude: [ /var/log/pods/observability_otel-agent*/*/*.log ] # never tail yourself
include_file_path: true
storage: file_storage # survive restarts: keep offsets
operators: [ { type: container } ]
processors:
memory_limiter:
check_interval: 1s
limit_percentage: 80 # of the container memory limit (cgroup)
spike_limit_percentage: 25 # soft limit = 55%
k8sattributes:
extract:
metadata: [ k8s.namespace.name, k8s.pod.name, k8s.deployment.name, k8s.node.name ]
# no pod labels or annotations by default: each one is a new dimension
pod_association:
- sources: [ { from: resource_attribute, name: k8s.pod.ip } ]
- sources: [ { from: connection } ] # the agent sees the real pod IP
resourcedetection: { detectors: [ env, system ], override: false }
batch: {}
exporters:
otlp/gateway:
endpoint: otel-gateway.observability.svc:4317
sending_queue:
storage: file_storage # persistent queue: replayed after restart
queue_size: 5000
retry_on_failure: { initial_interval: 5s, max_interval: 30s, max_elapsed_time: 300s }
service:
extensions: [ health_check, file_storage ]
pipelines:
traces: { receivers: [ otlp ], processors: [ memory_limiter, k8sattributes, resourcedetection, batch ], exporters: [ otlp/gateway ] }
metrics: { receivers: [ otlp, hostmetrics, kubeletstats ], processors: [ memory_limiter, k8sattributes, resourcedetection, batch ], exporters: [ otlp/gateway ] }
logs: { receivers: [ otlp, filelog ], processors: [ memory_limiter, k8sattributes, resourcedetection, batch ], exporters: [ otlp/gateway ] }Gateway tier 1 (stateless). Its job: normalize, derive RED metrics from all spans before any sampling, and fan out by signal.
otel-gateway.yaml
receivers:
otlp: { protocols: { grpc: { endpoint: 0.0.0.0:4317 } } }
processors:
memory_limiter: { check_interval: 1s, limit_percentage: 80, spike_limit_percentage: 25 }
transform/semconv: # normalize the old and new HTTP names (see: OpenTelemetry)
trace_statements:
- context: span
statements:
- set(attributes["http.request.method"], attributes["http.method"]) where attributes["http.request.method"] == nil and attributes["http.method"] != nil
resource/instance: # distinguish each gateway replica's spanmetrics series
attributes: [ { key: collector.instance, value: ${env:POD_NAME}, action: upsert } ]
batch: {}
connectors:
spanmetrics:
histogram: { explicit: { buckets: [ 5ms, 10ms, 25ms, 50ms, 100ms, 250ms, 500ms, 1s, 2.5s, 5s ] } }
dimensions: [ { name: http.request.method }, { name: http.route } ] # bounded only!
metrics_flush_interval: 15s
exporters:
loadbalancing:
routing_key: traceID
protocol: { otlp: { tls: { insecure: true }, sending_queue: { queue_size: 2000 } } }
resolver: { dns: { hostname: otel-sampler-headless.observability.svc, port: "4317" } }
prometheusremotewrite:
endpoint: http://mimir-gateway.mimir.svc/api/v1/push
headers: { X-Scope-OrgID: prod }
otlphttp/loki: { endpoint: http://loki-gateway.loki.svc/otlp }
service:
pipelines:
traces: { receivers: [ otlp ], processors: [ memory_limiter, transform/semconv, batch ], exporters: [ spanmetrics, loadbalancing ] }
metrics: { receivers: [ otlp, spanmetrics ], processors: [ memory_limiter, resource/instance, batch ], exporters: [ prometheusremotewrite ] }
logs: { receivers: [ otlp ], processors: [ memory_limiter, batch ], exporters: [ otlphttp/loki ] }Tier 2 (the sampling tier) is the same skeleton: otlp in, memory_limiter → tail_sampling → batch, otlp out to Tempo. Its policy, evaluated after decision_wait (default 30 s) with up to num_traces (default 50 000) held in memory:
tail_sampling:
decision_wait: 30s
num_traces: 50000
policies:
- { name: errors, type: status_code, status_code: { status_codes: [ ERROR ] } }
- { name: slow, type: latency, latency: { threshold_ms: 1000 } }
- { name: baseline, type: probabilistic, probabilistic: { sampling_percentage: 5 } }Backpressure, Queues, and "The Backend Is Down"
Every exporter has a sending queue (enabled: true, queue_size: 1000 requests, num_consumers: 10 by default) and retry (initial_interval: 5s, max_interval: 30s, max_elapsed_time: 300s, multiplier 1.5). The queue size unit is set by sizer (requests by default; items or bytes are more predictable for memory). When the backend stops answering:
- Exports fail. Each queued batch is retried with exponential backoff up to 5 minutes; after that it is dropped (
max_elapsed_time: 0would retry forever, which converts a data-loss problem into a memory or disk problem). - Meanwhile new data keeps arriving and fills the queue. At capacity, with the default
block_on_overflow: false, new data is rejected at enqueue. The error propagates up through the pipeline to the receiver and out to the sender, which is how backpressure reaches the tier upstream (gateway → agent → SDK). - Each upstream tier does the same with its own queue. The last stop is the application SDK's own bounded batch queue (the trace batch processor holds 2048 spans by default), which drops silently. A backend outage ultimately becomes dropped telemetry at the edge, with no error in any application.
- With a persistent queue (
sending_queue.storage: file_storage) the in-memory queue is replaced by a file on disk, so a restart replays what was pending. This protects against Collector restarts and short outages, not against a day-long outage with more data than disk.
Alternatives and Where They Fit
The OTel Collector is not the only data mover, and many shops run several. Choose by what the node is collecting and where the data is going:
| Tool | Origin / language | Strength | Weakness / note |
|---|---|---|---|
| OTel Collector | CNCF, Go | All three signals in one model, OTLP-native, huge component set, vendor-neutral | Config and component stability churn (still v0.x); heavier than Fluent Bit for pure log tailing |
| Fluent Bit | CNCF (Fluentd family), C | Very low footprint log shipper; the default log forwarder on many managed Kubernetes platforms; has OTLP in and out | Logs first; metrics and traces are not its centre of gravity |
| Fluentd | CNCF graduated, Ruby | Enormous plugin ecosystem, mature routing | Heavier than Fluent Bit; for new deployments Fluent Bit is the usual choice |
| Vector | Rust, now owned by Datadog | Fast, with a strong transform language (VRL) for logs and metrics; good as an aggregator | Vendor-owned; traces are not its strength, and its data model is not OTLP-native |
| Grafana Alloy | Grafana Labs, Go | An OTel Collector distribution plus built-in Prometheus pipelines and first-class Loki, Tempo and Pyroscope integration; one agent for the Grafana stack (see Grafana) | Uses its own configuration syntax (not Collector YAML); the best fit if the backend is Grafana |
| Datadog Agent | Datadog, Go | Turnkey for Datadog: checks, APM, logs, process data | Proprietary pipeline; OTLP is accepted but the Agent is built around the vendor, not around portability |
Production Traps
The Invariants
- Guarantees: Inside one pipeline, processors run in list order, so enrich/filter/sample/batch semantics are deterministic. With
loadbalancingontraceIDand a stable backend set, all spans of a trace reach one tier-2 replica. Receivers push back (refuse) whenmemory_limiteris first and tripped. A persistent queue replays pending exports after a restart. - Does not guarantee: Delivery. An in-memory queue, or data inside the batch processor, is lost on a crash; retries give up after
max_elapsed_time; a full queue drops by default; and an outage ends as silent drops at the SDK. It does not guarantee ordering across pipelines, nor cross-replica consistency for connector output (spanmetricsfrom N replicas needs a distinguishing label), nor stable config across minor versions (the Collector is still v0.x).