The OpenTelemetry Collector is the component that receives, processes, and exports traces, metrics, and logs without tying your platform to an observability vendor. On Kubernetes, it is usually the first building block of a standardized telemetry strategy: applications speak OTLP, the Collector enriches the data with cluster context and decides where to send it.
In this guide: how the Collector works, when to use the agent and gateway patterns, how to install it with Helm, and what to watch for in security, scaling, cost, and operations.
What the OpenTelemetry Collector is
The Collector is a single binary configured through a YAML file organized into pipelines. According to the configuration documentation, components fall into four classes, plus extensions:
- Receivers: receive or collect telemetry (OTLP, log files, kubelet metrics, and others).
- Processors: transform data along the way, for example adding attributes, filtering, or limiting memory usage.
- Exporters: send data to one or more destinations.
- Connectors: join two pipelines, acting as the exporter of one and the receiver of the other.
- Extensions: supporting capabilities, such as authentication mechanisms.
Two details prevent most first-time configuration mistakes:
- Declaring a component does not enable it. It only runs when it is referenced under
service.pipelines(thetraces,metrics, andlogspipelines). - The order of processors in a pipeline defines the order in which the operations are applied.
Agent or gateway: which deployment pattern to use
The documentation describes two main patterns, which are usually combined.
Agent. The Collector runs alongside the application or on the same host, as a sidecar or DaemonSet. According to the agent pattern page, it is the simplest way to get started and keeps a clear mapping between application and Collector; on the other hand, it scales poorly across many teams and is not very flexible in more complex scenarios.
Gateway. Applications (or agents) send data to a single OTLP endpoint served by Collectors running as a standalone service, for example a Deployment, typically one per cluster, data center, or region. The gateway pattern page highlights separation of concerns (credentials managed in one place) and centralized policies such as filtering and sampling. The price is one more component to maintain, added latency when Collectors are cascaded, and higher resource usage.
In practice:
- Use an agent as a DaemonSet for anything that depends on the node: pod logs, kubelet metrics, and enrichment with Kubernetes metadata.
- Use a gateway when you need centralized credentials, sampling, filtering, or routing to more than one backend.
- On platforms with several teams, the most common design is agents sending to a gateway.
Step by step: installing the Collector with Helm
The Kubernetes getting started guide recommends two installations of the same chart: a DaemonSet for node and workload telemetry and a Deployment for cluster telemetry.
1. Add the chart repository
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
helm repo update
The opentelemetry-collector chart requires the mode value to be set (daemonset, deployment, or statefulset). The official examples use the otel/opentelemetry-collector-k8s image.
2. Install the Collector as a DaemonSet
Create the values-daemonset.yaml file:
mode: daemonset
image:
repository: otel/opentelemetry-collector-k8s
presets:
kubernetesAttributes:
enabled: true
kubeletMetrics:
enabled: true
logsCollection:
enabled: true
helm install otel-collector open-telemetry/opentelemetry-collector \
-n observability --create-namespace \
--values values-daemonset.yaml
Presets, described in the chart documentation, are shortcuts that add components and the RBAC permissions they need:
kubernetesAttributes: adds thek8sattributesprocessor, which attaches metadata such ask8s.namespace.name,k8s.pod.name,k8s.deployment.name, andk8s.node.nameto telemetry.kubeletMetrics: adds thekubeletstatsreceiver, with node, pod, and container metrics.logsCollection: adds thefilelogreceiver, which reads pod logs on the node.
Each DaemonSet instance collects only the data from its own node. That is what prevents duplicate telemetry.
3. Install the cluster Collector as a Deployment
Create the values-cluster.yaml file:
mode: deployment
replicaCount: 1
image:
repository: otel/opentelemetry-collector-k8s
presets:
clusterMetrics:
enabled: true
kubernetesEvents:
enabled: true
helm install otel-collector-cluster open-telemetry/opentelemetry-collector \
-n observability \
--values values-cluster.yaml
The clusterMetrics preset adds the k8s_cluster receiver, and kubernetesEvents collects Kubernetes events. The documentation is explicit: both must run with exactly one replica, because more than one instance would produce duplicate data.
4. Configure where the data goes
By default, the chart sends telemetry only to the debug exporter. To reach a gateway or backend, declare an exporter and reference it in the pipelines:
config:
exporters:
otlp:
endpoint: otel-gateway.observability.svc.cluster.local:4317
tls:
ca_file: /etc/otel/tls/ca.crt
service:
pipelines:
traces:
exporters: [otlp]
metrics:
exporters: [otlp]
logs:
exporters: [otlp]
The endpoint and certificate path are illustrative; the CA file must be mounted into the pod from a Secret. Before applying, render the result with helm template and check the generated ConfigMap: lists defined in your values replace the chart's lists, and a manually configured pipeline must list all of its components.
In production, pin the chart version (--version <version>) and the image tag, and promote upgrades across environments through GitOps.
Operational best practices
Security
The project's security best practices point to five main precautions:
- Expose only what is needed. The Collector defaults to
localhostfor endpoints; the examples with0.0.0.0exist for convenience. On Kubernetes, prefer binding the receiver to a specific interface, such as the pod IP. - Use encryption and authentication. Receivers accept
cert_fileandkey_file; exporters validate the server withca_file. Theinsecureandinsecure_skip_verifyoptions are not recommended. - Keep credentials out of versioned YAML. Use environment variables with the
${env:VARIABLE_NAME}syntax, fed by a Secret or a secret store. - Reduce the attack surface. Keep only the components you need and run the Collector without root privileges.
- Handle sensitive data before exporting. The filter and redaction processors help remove or mask attributes, which also supports compliance with data protection laws.
Memory, queues, and scaling
The scaling page lists the signals that should drive the decision to scale:
otelcol_processor_refused_spans: data refused by thememory_limiter. It indicates a lack of memory or replicas.otelcol_exporter_queue_sizeandotelcol_exporter_queue_capacity: exporter queue usage. The guidance is to consider scaling when the queue reaches 60–70% of capacity.otelcol_exporter_enqueue_failed_spans: data rejected because the queue is full.otelcol_exporter_send_failed_spans: failures sending to the destination. In this case, the bottleneck is the backend or the network, and adding replicas only increases the pressure.
Stateless components scale with replicas behind a load balancer. For OTLP over gRPC, load balancing must happen at layer 7, because a layer 4 load balancer keeps the connection pinned to a single backend.
Stateful components need more care. Tail sampling requires all spans of a trace to reach the same instance. The documented design uses two tiers: the first with the load-balancing exporter routing by trace ID and the second with the tail sampling processor.
For Prometheus-format metric collection at scale, the Target Allocator, shipped with the OpenTelemetry Operator, distributes scrape targets across Collectors.
Avoid duplicate series
The specification requires each metric stream to have a single writer and a unique identity. Two Collectors scraping the same target cause overwrites, gaps, and out-of-order sample errors in Prometheus-compatible backends. Hence the preset rules: node-level collection runs as a DaemonSet; cluster-level collection runs as a single replica.
Monitor the Collector itself
The Collector exposes internal telemetry in Prometheus format, by default on port 8888. Scrape these metrics and create alerts for the exporter queue, send failures, and refused data. An unmonitored observability pipeline fails silently, and the loss only shows up when someone looks for a trace that does not exist.
Cost
Telemetry has network, processing, and storage costs. The gateway is the natural place to apply filtering and sampling before data reaches a backend billed by volume. In return, it consumes resources of its own: size requests and limits based on internal metrics, not estimates.
Common mistakes
- Running
clusterMetricsorkubernetesEventswith more than one replica and duplicating data. - Enabling
logsCollectionwhile keeping thedebugexporter on logs: the Collector starts reading its own output, and volume grows in a loop. - Using
0.0.0.0on every receiver because the examples do. - Adding replicas when the problem is a saturated backend.
- Applying tail sampling across several replicas without routing by trace ID.
- Using
latestfor the image or leaving the chart version unpinned.
Frequently asked questions
Do I need the OpenTelemetry Operator to use the Collector?
No. The Helm chart installs the Collector directly. The Operator makes sense when you want to manage Collectors as Kubernetes resources, use workload auto-instrumentation, or use the Target Allocator.
Can I use only the gateway, without agents?
Yes, for telemetry that applications send over OTLP. Pod logs and kubelet metrics depend on node access, which is why they are collected by a DaemonSet.
Does the Collector replace Prometheus or the observability backend?
No. The Collector receives, processes, and forwards telemetry, but it does not store or query data. It works together with metrics, logs, and traces backends.
Conclusion
The OpenTelemetry Collector on Kubernetes delivers more value when the design is decided before installation: a DaemonSet for node-level data, a single replica for cluster-level data, a gateway for centralized policies, and internal metrics to know when to scale. With that in place, replacing or adding a backend becomes a configuration change, not a re-instrumentation project.
CloudScript implements this pattern as part of its Observability and SRE services, with declarative delivery through GitOps and 24/7 support for customers under contract. If the topic also involves reducing your telemetry bill, the guide on AWS Cost Anomaly Detection is worth reading. To review observability in your environment, talk to us or write to contato@cloudscript.com.br.
Sources
- OpenTelemetry — Collector
- OpenTelemetry — Agent deployment pattern
- OpenTelemetry — Gateway deployment pattern
- OpenTelemetry — Collector configuration
- OpenTelemetry — Getting started on Kubernetes
- OpenTelemetry — Collector Helm chart
- OpenTelemetry — Collector components for Kubernetes
- OpenTelemetry — Scaling the Collector
- OpenTelemetry — Configuration security best practices
- OpenTelemetry — Internal telemetry
- OpenTelemetry — Operator for Kubernetes
OpenTelemetry, Kubernetes, Helm, and Prometheus are trademarks of The Linux Foundation. All other trademarks belong to their respective owners. Use is nominative only and does not imply endorsement.



