What is the OpenTelemetry Collector, and how to size it
The OpenTelemetry Collector is a process that receives telemetry, processes it and forwards it to one or more destinations. It doesn't belong to any vendor. This guide explains how it's built, where to deploy it, and how to tell how much memory and how many instances it needs.
What it's for
Without a Collector, every application talks straight to the observability backend. It works, but every change of destination, credential or rule means touching all your applications. The Collector sits in the middle and solves four things:
- It receives from everything: OTLP from your applications, and also log files, system metrics, Prometheus, SNMP and dozens of other sources.
- It processes: filters noise, adds attributes (host, cloud, Kubernetes), masks sensitive data, samples traces.
- It protects: if the destination stops responding, it queues the data and retries, instead of losing it or stalling the application.
- It decouples: switching platforms, or sending to two at once, is a configuration change in one place.
How it's built
The configuration is a YAML file with five kinds of components:
- Receivers: where telemetry comes in.
- Processors: what happens to it along the way. Order matters.
- Exporters: where it goes out.
- Connectors: join two pipelines; for example, they generate metrics from traces.
- Extensions: support services that don't touch the data: health checks, disk storage for queues, authentication.
Components are declared once and then wired into pipelines, one per signal (traces, metrics, logs). A component that is declared but isn't in any pipeline does nothing: a common mistake.
Which distribution to use
The Collector is published in several distributions. Core ships the minimum. Contrib ships all the community components and is the easiest way to start. For production at scale, build your own with the official ocb tool, with only the components you use: a smaller image with less surface area for vulnerabilities.
Where to deploy it
- Agent: a Collector next to the application, or one per host or node. It receives from what runs on that machine and also collects its logs and metrics.
- Gateway: a pool of central Collectors, behind a load balancer, that receives from all the agents. It's the place for shared rules, the destination credentials and trace sampling.
The usual setup combines both: lightweight agents that forward to a gateway. With only a few hosts, the agent alone is enough.
A production-ready Collector
This example adds three things to the minimal Collector that you need to avoid losing data: a memory limit, a disk queue and retries.
extensions:
health_check: # so the orchestrator knows it's alive
endpoint: 0.0.0.0:13133
file_storage: # the queue survives a restart
directory: /var/lib/otelcol/queue
create_directory: true
receivers:
otlp:
protocols:
grpc: { endpoint: 0.0.0.0:4317 }
http: { endpoint: 0.0.0.0:4318 }
processors:
memory_limiter: # always first
check_interval: 1s
limit_percentage: 80
spike_limit_percentage: 20
batch: {} # always last
exporters:
otlphttp:
endpoint: https://ingest.oneglass.io
headers:
Authorization: "Api-Token ${env:ONEGLASS_INGEST_KEY}"
X-Tenant-ID: "${env:ONEGLASS_TENANT_ID}"
retry_on_failure:
enabled: true
max_elapsed_time: 300s # after 5 minutes of failures, it drops the data
sending_queue:
enabled: true
queue_size: 5000
storage: file_storage # without this line the queue lives in memory
service:
extensions: [health_check, file_storage]
telemetry:
metrics:
level: detailed # the Collector's own metrics
pipelines:
traces: { receivers: [otlp], processors: [memory_limiter, batch], exporters: [otlphttp] }
metrics: { receivers: [otlp], processors: [memory_limiter, batch], exporters: [otlphttp] }
logs: { receivers: [otlp], processors: [memory_limiter, batch], exporters: [otlphttp] }The exporter in the example points at OneGlass; with any other OTLP destination, only the endpoint and the headers change.
How to size it
There's no single number that works for everyone: consumption depends on volume, on the size of each item, and on the processors you use. What does exist is a method.
1. Set the memory limit in three places
- The container or service limit: the real ceiling.
- The
GOMEMLIMITvariable, at around 80% of that ceiling: it tells the Go runtime when to free memory more aggressively. - The
memory_limiterprocessor: when it nears the limit, the Collector refuses new data instead of dying. The sender gets an error and retries.
Without all three, a traffic spike ends in an out-of-memory restart, and everything in flight is lost.
2. Measure with your own traffic
Start with one instance, send it real traffic, and watch CPU and memory for a full day, peaks included. That consumption per thousand spans or log lines per second is your number, and it's worth more than anyone else's table.
3. Scale horizontally
A Collector that only receives OTLP and forwards it keeps no state: you scale it by adding instances behind a load balancer. Two details that often surprise people:
- gRPC keeps connections open. A layer 4 load balancer spreads connections, not requests, and one instance can end up with almost all the traffic. Use a load balancer that understands gRPC, or export over HTTP.
- Tail sampling needs the whole trace. All the spans of a trace have to reach the same instance. You solve it with a first layer of Collectors that distributes by trace ID using the
loadbalancingexporter.
4. Size the queue for the outage you want to ride out
The send queue defines how long the destination can be down without you losing data. If you want to ride out ten minutes, the queue has to be able to hold ten minutes of your traffic. In memory that costs RAM; on disk, with file_storage, it costs space and also survives a restart.
Signs that it's falling short
The Collector publishes metrics about itself. Four of them are enough to know whether it's sized right:
otelcol_exporter_queue_sizeagainstotelcol_exporter_queue_capacity: if the queue grows and doesn't drain, the destination can't keep up or you need another instance.otelcol_exporter_enqueue_failed_spans(and its metrics and logs counterparts): the queue filled up and data is being dropped.otelcol_receiver_refused_spans: the Collector is refusing what it's sent, almost always becausememory_limiterkicked in.otelcol_exporter_send_failed_spans: the destination rejects the data or doesn't respond.
Send those metrics to your observability platform and set an alert on the last three. A Collector that silently drops data is worse than one that's down, because nobody notices.
Common mistakes
- Putting
memory_limiteranywhere. It goes first in each pipeline; after other processors it's already too late. - Leaving the queue in memory on a gateway. A restart during a destination outage loses everything accumulated.
- Running the full contrib distribution in production forever. It's fine for starting out; later, an image with just what you need is better.
- Not watching the Collector's own metrics. All your telemetry passes through it: it deserves its own dashboard.
- Configuring each instance by hand. The OpAMP protocol lets you manage the configuration of the whole fleet remotely.
With OneGlass
OneGlass is an observability platform built natively on OpenTelemetry, made in Argentina. It receives standard OTLP from any Collector. With OneGlass Pipelines you manage your Collectors over OpAMP from one place: what they collect, how they transform it, and where they send it, to OneGlass or to any other OTLP endpoint.