Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

OpenTelemetry Collector: the router for your observability data

29 min read
Improve this page

Logo OpenTelemetry

The OpenTelemetry Collector is an intermediary between your applications and your observability backends. Instead of sending your traces directly to Jaeger, your metrics to Prometheus and your logs to Loki, your applications send everything to the Collector over OTLP, and it takes care of distributing the data to the right places.

This lesson follows the previous one, which made applications emit telemetry. The configurations target 0.155.0, the version pinned in the commands.

What you will learn

  • Explain the role of the Collector and the path of a piece of data: receivers, processors, exporters
  • Install the Collector with Docker, Helm or the binary, at a pinned version
  • Build a first pipeline that sends traces to Jaeger, and check that a trace arrives
  • Connect an application by choosing the right OTLP port and protocol
  • Write a full pipeline for traces, metrics and logs
  • Troubleshoot the most frequent pipeline failures

What is the Collector for?

The Collector decouples your applications' code from your infrastructure choices: the application speaks a single protocol, and routing to the backends becomes a matter of configuration.

The problem without a Collector

Picture a Python application that has to send traces to Jaeger, metrics to Prometheus and logs to Loki. Without a Collector, each backend imposes its own SDK, format and configuration:

# Each backend has its own SDK, format, config
from jaeger_client import Config as JaegerConfig
from prometheus_client import start_http_server
import logging_loki
# 3 different connections, 3 different formats
jaeger_tracer = JaegerConfig(...).initialize_tracer()
start_http_server(8000) # Prometheus endpoint
loki_handler = logging_loki.LokiHandler(url="http://loki:3100/...")

Three drawbacks follow, and they grow with the number of services:

  • If you change the traces backend (Jaeger → Tempo), you change the code
  • Each service has its own connection config
  • No filtering, no data transformation

The solution: the Collector as an intermediary

With the Collector, your applications send everything to the same place, and the diagram below reads from left to right: each piece of data goes through a receiver, processors, then an exporter towards its backend.

The application sends traces, metrics and logs over OTLP to the Collector, where they go through a receiver, a processor then an exporter, which distributes them to Tempo for traces, Prometheus for metrics and Loki for logs.BackendsOpenTelemetry CollectorApplicationOTLP: traces,metrics, logsYour appPython, Go, Java, Node…ReceiverOTLPProcessorbatch, filterExporterOTLP, LokiTempotracesPrometheusmetricsLokilogs
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

The benefits read as a point-by-point answer to the previous drawbacks:

  • Simpler code: your app only knows OTLP, not the backends
  • Backend change: modify the Collector config, not the code
  • Transformation: filter, enrich, sample the data before sending
  • Resilience: the Collector buffers if a backend is temporarily unavailable

Understanding the architecture

The Collector works as a three-stage pipeline, declared in a single YAML file: receivers receive, processors transform, exporters send. The service section then assembles these building blocks into pipelines, one per signal.

1. Receivers: receiving the data

Receivers listen on ports and ingest incoming data. For a new application, otlp is enough; the others serve to integrate existing tools.

ReceiverWhat it receivesDefault port
otlpTraces, metrics, logs in OpenTelemetry format4317 (gRPC), 4318 (HTTP)
jaegerTraces in Jaeger format14268
prometheusMetrics scraped from endpoints-
filelogLogs from files-

2. Processors: transforming the data

Processors modify the data between reception and sending. Two of them belong in every pipeline, in this order: memory_limiter first, to protect the Collector, then batch.

ProcessorWhat it doesWhen to use it
batchGroups data (reduces network traffic)Always
memory_limiterPrevents OOMs by limiting memoryAlways
filterDrops useless dataReduce costs
attributesAdds/removes metadataEnrich or mask sensitive data
k8sattributesAdds Kubernetes metadata (pod, namespace…)On Kubernetes

3. Exporters: sending to the backends

Exporters pass the data on to the final backends. Their names have changed: on 0.155.0, the old otlp and prometheusremotewrite aliases still work but produce a warning at startup, and the loki exporter has disappeared, rejected with unknown type: "loki". The table gives the current names.

ExporterDestinationWhen to use it
otlp_grpcAny OTLP-compatible backend over gRPC (Tempo, Jaeger…)Traces and metrics
otlp_httpOTLP backend over HTTP, including Loki 3 on its /otlp endpointLogs to Loki, or if gRPC is blocked
prometheus_remote_writePrometheus, Mimir, CortexMetrics
debugConsole (stdout)Troubleshooting

Installing the Collector

Three installation modes, for three contexts: Docker to try it out on a workstation, Helm for a Kubernetes cluster, the binary for a machine without containers. The YAML configuration is the same in all three cases.

  1. Create a configuration file

    config.yaml
    receivers:
    otlp:
    protocols:
    grpc:
    endpoint: 0.0.0.0:4317
    http:
    endpoint: 0.0.0.0:4318
    processors:
    memory_limiter:
    check_interval: 1s
    limit_mib: 512
    spike_limit_mib: 128
    batch:
    timeout: 5s
    exporters:
    debug:
    verbosity: detailed
    extensions:
    health_check:
    endpoint: 0.0.0.0:13133
    zpages:
    endpoint: 0.0.0.0:55679
    service:
    extensions: [health_check, zpages]
    pipelines:
    traces:
    receivers: [otlp]
    processors: [memory_limiter, batch]
    exporters: [debug]

    This minimal config:

    • Listens for OTLP on ports 4317 (gRPC) and 4318 (HTTP)
    • Limits memory (memory_limiter) to avoid OOMs
    • Groups data in 5-second batches
    • Enables health_check (port 13133) and zpages (port 55679) for diagnostics
    • Prints traces to the console (to check that it works)
  2. Run the Collector

    Terminal window
    docker run -d \
    --name otel-collector \
    -p 127.0.0.1:4317:4317 \
    -p 127.0.0.1:4318:4318 \
    -p 127.0.0.1:13133:13133 \
    -v $(pwd)/config.yaml:/etc/otelcol-contrib/config.yaml:ro \
    otel/opentelemetry-collector-contrib:0.155.0@sha256:4935caa35e9a4cb387e35732e8fb22b2b5759af8d12e7043357f03837f6e8df5

    The image is pinned by its tag and its digest: the tag alone can be moved, and :latest would introduce incompatible changes without warning.

    Why contrib? There are two images: opentelemetry-collector (core) and opentelemetry-collector-contrib. Use contrib: it includes the community receivers and exporters you will need, such as prometheus_remote_write.

  3. Check that it works

    Terminal window
    # Check the logs
    docker logs otel-collector
    # Check the health check
    curl http://localhost:13133/

    What you should see (real output from 0.155.0, shortened):

    info service@v0.155.0/service.go:256 Starting otelcol-contrib...
    info service@v0.155.0/service.go:279 Everything is ready. Begin running and processing data.

    The health check returns:

    {"status":"Server available","upSince":"2026-10-08T03:56:34.69088127Z","uptime":"4.970807372s"}

    If you see Everything is ready and the health check passes, the Collector is operational.

Your first pipeline: traces to Jaeger

Now that the Collector is running, let's configure a realistic pipeline that sends traces to Jaeger, a traces backend that is easy to run locally. We use Jaeger 2, since branch 1 has reached end of life.

Prerequisites

The Collector and Jaeger must reach each other by name: a dedicated Docker network takes care of that, and only Jaeger's interface port is published on the workstation.

Terminal window
# Create a shared network
docker network create observability
# Start Jaeger (only the UI exposed)
docker run -d --name jaeger \
--network observability \
-p 127.0.0.1:16686:16686 \
jaegertracing/jaeger:2.22.0@sha256:836b967b5abcf1f7758066aa6b348619267a2f1459f72d472840570f9bd88a17

The Jaeger interface is at http://localhost:16686.

Configuration

The file reuses the minimal configuration and adds an otlp_grpc/jaeger exporter: the suffix after the slash is a free name, which lets you declare several exporters of the same type.

config.yaml
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
processors:
memory_limiter:
check_interval: 1s
limit_mib: 512
spike_limit_mib: 128
batch:
timeout: 5s
send_batch_size: 1000
exporters:
# Export to Jaeger via OTLP
otlp_grpc/jaeger:
endpoint: jaeger:4317
tls:
insecure: true
# Keep debug to see what goes through
debug:
verbosity: basic
extensions:
health_check:
endpoint: 0.0.0.0:13133
zpages:
endpoint: 0.0.0.0:55679
service:
extensions: [health_check, zpages]
pipelines:
traces:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [otlp_grpc/jaeger, debug]

The path of a trace reads in four steps:

  1. Applications send OTLP traces to the Collector (port 4317 or 4318)
  2. The Collector limits memory (memory_limiter) to avoid OOMs
  3. Traces are grouped in batches of 1000 or every 5 seconds
  4. Traces are sent to Jaeger AND printed in the logs (debug)

Restart the Collector

The Collector must join the observability network to resolve the name jaeger: we recreate it with the new configuration, also publishing the zpages port.

Terminal window
# Stop the old collector
docker stop otel-collector && docker rm otel-collector
# Restart with the network and the new config
docker run -d \
--name otel-collector \
--network observability \
-p 127.0.0.1:4317:4317 \
-p 127.0.0.1:4318:4318 \
-p 127.0.0.1:13133:13133 \
-p 127.0.0.1:55679:55679 \
-v $(pwd)/config.yaml:/etc/otelcol-contrib/config.yaml:ro \
otel/opentelemetry-collector-contrib:0.155.0@sha256:4935caa35e9a4cb387e35732e8fb22b2b5759af8d12e7043357f03837f6e8df5

Connecting your applications to the Collector

Your applications only need to know one address, the Collector's. There are three ways to get there, from the most explicit to the most declarative: the SDK in the code, auto-instrumentation at launch, environment variables on Kubernetes.

The SDK is configured in the code: you create an OTLP exporter that targets the Collector, then a tracer provider that uses it. The examples below do the same thing in four languages.

Terminal window
pip install opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp
app.py
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
# Configure the OTLP exporter towards the Collector
otlp_exporter = OTLPSpanExporter(
endpoint="http://localhost:4317", # Collector address
insecure=True
)
# Configure the tracer
provider = TracerProvider()
provider.add_span_processor(BatchSpanProcessor(otlp_exporter))
trace.set_tracer_provider(provider)
# Use it
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("my-operation"):
# Your code here
print("This operation is traced!")

Option 2: Auto-instrumentation (zero code)

For popular frameworks, OpenTelemetry instruments the application without changing its code: a launcher or an agent intercepts the libraries at startup, and environment variables give the Collector address and the protocol to use.

Terminal window
pip install opentelemetry-distro opentelemetry-exporter-otlp
opentelemetry-bootstrap -a install
Terminal window
# Run your app with auto-instrumentation
OTEL_SERVICE_NAME=my-service \
OTEL_EXPORTER_OTLP_PROTOCOL=grpc \
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 \
opentelemetry-instrument python app.py

Option 3: Environment variables (Kubernetes)

On Kubernetes, the configuration goes through the container's environment variables: the Collector address uses the cluster's internal DNS, here the otel-collector service in the observability namespace.

deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-service
spec:
template:
spec:
containers:
- name: app
image: my-image:1.0.0
env:
- name: OTEL_SERVICE_NAME
value: "my-service"
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: "http://otel-collector.observability.svc:4317"
- name: OTEL_EXPORTER_OTLP_PROTOCOL
value: "grpc"
- name: OTEL_TRACES_EXPORTER
value: "otlp"

Validation: checking that it works

Validation is done end to end: you generate a test trace, see it go by in the Collector logs, then find it in Jaeger. The commands target 0.155.0 and Jaeger 2.22.0.

  1. Generate test traffic

    If you do not have an instrumented application yet, use telemetrygen:

    Terminal window
    docker run --rm --network observability \
    ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:v0.155.0@sha256:32d1762abb401e36dd8cfdf60a71075b41bd996a0cfb7c8d2e6eac4d609625b9 \
    traces --otlp-insecure --otlp-endpoint otel-collector:4317 --traces 1

    The --traces 1 option is mandatory: without it, telemetrygen stops with either traces or duration must be greater than 0. Also note the v prefix of the image tag, which does not exist without it.

  2. Check the Collector logs

    Terminal window
    docker logs otel-collector --tail 50

    With verbosity: basic, the debug exporter writes one info Traces line per batch received, with the number of spans: it is the proof that the trace went through the pipeline.

  3. Check in Jaeger

    Open http://localhost:16686, select the telemetrygen service in the drop-down menu then click Find Traces. On the command line, the Jaeger 2 v3 API lists the known services:

    Terminal window
    curl -s http://localhost:16686/api/v3/services
    {"services":["telemetrygen"]}

Full pipeline: metrics, logs and traces

A single configuration can carry the three signals, each in its own pipeline: traces to Tempo, metrics to Mimir, logs to Loki through its native OTLP endpoint. On 0.155.0, this file passes otelcol-contrib validate and starts without any alias warning.

config-complet.yaml
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
# Scrape the apps' Prometheus metrics
prometheus:
config:
scrape_configs:
- job_name: 'applications'
scrape_interval: 30s
static_configs:
- targets: ['app1:8080', 'app2:8080']
processors:
memory_limiter:
check_interval: 1s
limit_mib: 512
spike_limit_mib: 128
batch:
timeout: 5s
send_batch_size: 1000
# Add attributes to all the data
resource:
attributes:
- key: deployment.environment.name
value: production
action: insert
exporters:
# Traces to Tempo
otlp_grpc/tempo:
endpoint: tempo:4317
tls:
insecure: true
# Metrics to Mimir (remote write compatible)
prometheus_remote_write:
endpoint: http://mimir:9009/api/v1/push
# Logs to Loki, through its native OTLP endpoint (Loki 3)
otlp_http/loki:
endpoint: http://loki:3100/otlp
debug:
verbosity: basic
extensions:
health_check:
endpoint: 0.0.0.0:13133
zpages:
endpoint: 0.0.0.0:55679
service:
extensions: [health_check, zpages]
pipelines:
traces:
receivers: [otlp]
processors: [memory_limiter, resource, batch]
exporters: [otlp_grpc/tempo, debug]
metrics:
receivers: [otlp, prometheus]
processors: [memory_limiter, resource, batch]
exporters: [prometheus_remote_write]
logs:
receivers: [otlp]
processors: [memory_limiter, resource, batch]
exporters: [otlp_http/loki]

Loki: watch the cardinality. Through the OTLP endpoint, Loki stores the most common resource attributes (service.name, k8s.namespace.name…) as labels, and the rest as line metadata. A high-variety attribute set at the resource level, such as a request ID, would become a label and multiply the streams: keep these values in the log attributes, never in the resource.

Troubleshooting

Most failures sit between the Collector and its backend: the trace arrives (it shows up in debug) but does not leave. The table reads in the order of the flow, and the diagnostic block that follows covers each row.

SymptomLikely causeSolution
connection refusedCollector not running or wrong endpointdocker ps + check the URL
No traces in JaegerExporter misconfiguredCheck the Collector logs
Traces in logs but not in the backendBackend unreachableTest the connection: curl backend:port
Collector OOMNo memory_limiterAdd the processor first
Data lostBatch too big or timeout too shortReduce send_batch_size
Health check failsCollector crashed or badly starteddocker logs otel-collector
Connection reset towards port 4317SDK or agent sending http/protobuf to the gRPC portOTEL_EXPORTER_OTLP_PROTOCOL=grpc, or target port 4318
unknown type: "loki" at startupExporter removed from the Collectorotlp_http to http://loki:3100/otlp
zpages unreachableExtension not enabled or wrong portCheck service.extensions

Diagnostic commands

These commands go from the simplest to the finest. The zpages expose the internal state: pipelinez lists the pipelines and their components, servicez the version and the loaded configuration. On 0.155.0, tracez answers 404: the page is no longer available.

Terminal window
# Collector state
docker ps | grep otel-collector
# Health check
curl http://localhost:13133/
# Recent logs
docker logs otel-collector --tail 100
# Validate the configuration
docker exec otel-collector otelcol-contrib validate --config /etc/otelcol-contrib/config.yaml
# Pipeline debug (zpages)
curl http://localhost:55679/debug/pipelinez
curl http://localhost:55679/debug/servicez

How do you diagnose a pipeline that delivers nothing?

A pipeline that delivers nothing is diagnosed with the Collector's internal metrics, never with its health_check. Enable the service.telemetry block so that the Collector publishes its otelcol_* counters on port 8888. Keep two traps in mind: a green health_check does not prove that the export to the backend works, it only says that the Collector is running; and a missing otelcol_receiver_accepted_spans series is not a zero, it means that nothing reaches the receiver. The four failures explained, the configuration and the reading method are in the dedicated lesson, Diagnosing an OpenTelemetry pipeline that delivers nothing (in French).

Production checklist

Before going to production, validate these points. Each one picks up a step of the lesson, and most can be checked with one command or one line of configuration.

  • Pinned version: tag and digest, never :latest
  • No port conflict: Jaeger and Collector on the same Docker network
  • health_check enabled: curl localhost:13133/ returns Server available
  • memory_limiter configured: prevents OOMs
  • Internal metrics enabled: service.telemetry and port 8888, to read otelcol_*
  • debug exporter removed: or set to verbosity: basic
  • Current exporter names: otlp_grpc, otlp_http, prometheus_remote_write
  • OTLP protocol declared: OTEL_EXPORTER_OTLP_PROTOCOL avoids gRPC/HTTP surprises
  • Bind to localhost in dev: -p 127.0.0.1:4317:4317
  • Loki labels under control: low cardinality (service, namespace, level)
  • Kubernetes: clear choice between DaemonSet (agent) and Deployment (gateway)

Key takeaways

  • The Collector is an intermediary between your apps and your backends
  • Receiver → Processor → Exporter architecture for each pipeline
  • Always use memory_limiter and batch (in this order)
  • Enable health_check and zpages for diagnostics
  • Your apps send OTLP: port 4317 (gRPC) or 4318 (HTTP)
  • The default protocol depends on the SDK (the Java 2.x agent sends http/protobuf): declare OTEL_EXPORTER_OTLP_PROTOCOL
  • With Helm, the image block is mandatory and each exporter must appear in a pipeline to send anything
  • Pin the versions, and check the exporter names on every upgrade: loki has disappeared, otlp became otlp_grpc
  • Change backend by modifying the config, not the code