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.

ComponentWhat it doesExamples
ReceiverGets 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
ProcessorTransforms, enriches, filters or batches data in flight. They run in list order.memory_limiter, batch, k8sattributes, resource, attributes, filter, transform, tail_sampling
ExporterSends data out, with its own retry and queue.otlp, otlphttp, prometheusremotewrite, loadbalancing, debug
ConnectorIs 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
ExtensionNot 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)
Three horizontal pipelines inside one Collector. The traces pipeline receives otlp, runs memory_limiter, k8sattributes, transform, batch, then exports to Tempo via otlp and also feeds the spanmetrics connector. The metrics pipeline receives otlp, prometheus, hostmetrics, kubeletstats, plus the spanmetrics and count connectors as receivers, runs memory_limiter, k8sattributes, transform, batch, and exports with prometheusremotewrite to Mimir. The logs pipeline receives otlp and filelog, runs memory_limiter, k8sattributes, filter, batch, and exports through otlphttp to Loki and also feeds the count connector, which counts log records into a metric on the metrics pipeline.
One Collector's internal graph: three signals, two connectors that cross between pipelines. Read it as: the three lanes are independent pipelines that share only a process and a memory budget. Every lane starts with memory_limiter and ends with batch; the two amber paths are the only way data crosses lanes, and they are why one trace stream can also produce RED metrics. There is deliberately no tail_sampling in this lane: a connector sees whatever its pipeline passed, so span metrics must be computed from unsampled spans (see the tier diagram below).

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:

DistributionContainsUse it for
otelcol (core)OTLP, a few basic processors and exporters, the core extensionsMinimal base; rarely enough on its own (no k8sattributes, no filelog, no prometheusremotewrite)
otelcol-contribEverything in the contrib repo: hundreds of receivers, processors, exportersPrototyping. In production it is a large attack surface and a larger binary for components you do not use
otelcol-k8sA curated subset for Kubernetes node and cluster collectionAgent/gateway on Kubernetes without custom builds
Custom, built with ocb (OpenTelemetry Collector Builder)Exactly the components in a manifest you writeProduction: 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.0

Most 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:

  1. memory_limiter first. It samples process memory every check_interval and, 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. Set check_interval: 1s (the default is 0, i.e. unset) and make the limit about 80% of the container memory limit, with limit_percentage / spike_limit_percentage reading cgroup limits automatically on Linux. spike_limit_mib defaults to 20% of the limit.

  2. Enrich next: k8sattributes, resourcedetection, resource. k8sattributes looks up the pod from the incoming connection and adds k8s.namespace.name, k8s.pod.name, deployment, node, and (optionally) selected pod labels. It needs RBAC to list and watch pods, namespaces and nodes. resourcedetection adds cloud.*, host.* from the environment. resource and attributes set, rename or delete fixed attributes.

  3. Cut: filter then transform. filter drops whole telemetry matching an OTTL condition (health-check spans, DEBUG logs, noisy metrics). OTTL (OpenTelemetry Transformation Language) is a small expression language used by filter, transform and some connectors: delete_key(attributes, "user.id"), set(attributes["env"], resource.attributes["deployment.environment.name"]). Use transform to normalize semconv generations, drop high-cardinality attributes and redact. Filtering before heavy work saves CPU for everything after it.

  4. tail_sampling late, before batch, and only on the tier that has whole traces (see topology below, and the Distributed Tracing guide).

  5. 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

ReceiverMechanismGotcha
otlpListens 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.
prometheusEmbeds 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.
filelogTails 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.
hostmetricsReads 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.
kubeletstatsQueries 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 canRead 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 nodeMake cluster-wide decisions: tail sampling, global rate limits, central credentials to backends, one egress point
CostN 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 scopeOne node's telemetryWhole cluster, if undersized or a single replica
Three Kubernetes nodes each contain application pods sending OTLP to a local agent DaemonSet. All three agents send OTLP to gateway tier one, a stateless Deployment of several replicas behind a Service, which runs batch and the loadbalancing exporter. Traces only go from tier one to gateway tier two, a set of replicas running tail_sampling where every trace ID is routed to exactly one replica, and from there to Tempo. Metrics and logs bypass tier two and go from tier one directly to Mimir and Loki. A note says a single gateway replica is a single point of failure and that tier two must not be scaled without understanding that trace routing changes.
Agent per node, stateless gateway, a separate stateful tail-sampling tier. Read it as: only traces take the detour through the stateful tier. Metrics and logs have no equivalent "whole object on one machine" requirement, so they go straight to storage, and a failure of the sampling tier loses only trace data.

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:

  1. Exports fail. Each queued batch is retried with exponential backoff up to 5 minutes; after that it is dropped (max_elapsed_time: 0 would retry forever, which converts a data-loss problem into a memory or disk problem).
  2. 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).
  3. 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.
  4. 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:

ToolOrigin / languageStrengthWeakness / note
OTel CollectorCNCF, GoAll three signals in one model, OTLP-native, huge component set, vendor-neutralConfig and component stability churn (still v0.x); heavier than Fluent Bit for pure log tailing
Fluent BitCNCF (Fluentd family), CVery low footprint log shipper; the default log forwarder on many managed Kubernetes platforms; has OTLP in and outLogs first; metrics and traces are not its centre of gravity
FluentdCNCF graduated, RubyEnormous plugin ecosystem, mature routingHeavier than Fluent Bit; for new deployments Fluent Bit is the usual choice
VectorRust, now owned by DatadogFast, with a strong transform language (VRL) for logs and metrics; good as an aggregatorVendor-owned; traces are not its strength, and its data model is not OTLP-native
Grafana AlloyGrafana Labs, GoAn 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 AgentDatadog, GoTurnkey for Datadog: checks, APM, logs, process dataProprietary 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 loadbalancing on traceID and a stable backend set, all spans of a trace reach one tier-2 replica. Receivers push back (refuse) when memory_limiter is 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 (spanmetrics from N replicas needs a distinguishing label), nor stable config across minor versions (the Collector is still v0.x).