Video in progress

Should the OpenTelemetry Collector run as an agent (on every node) or as a gateway (central)? How do you design the telemetry pipeline?

Usually both together: an agent on the node (DaemonSet) receives data close to the application, adds Kubernetes metadata and buffers quickly; a central gateway handles tail sampling, redaction, routing and export to the backends. The application doesn't know about the backend, and the policy lives in one place.

📖 Answer

The goal of the pipeline is that the application only knows how to "send OTLP to localhost", and everything else is handled by the platform.

[app pod] --OTLP--> [agent collector (DaemonSet)]
                          | k8sattributes, memory_limiter, batch
                          v
                [loadbalancing exporter, by traceID]
                          v
               [gateway collector (Deployment, N replicas)]
                 | tail_sampling, redaction, filter, routing
                 +--> Tempo / Jaeger (traces)
                 +--> Mimir / Prometheus remote write (metrics)
                 +--> Loki / Elasticsearch (logs)

What the agent layer gives you:

  • the network is close and cheap for the application; if the backend slows down, the agent buffers, not the application;
  • the k8sattributes processor adds the pod, namespace and deployment name, so the application doesn't have to know them;
  • you can also collect host metrics and container logs here.

What the gateway layer gives you:

  • tail sampling: all spans of one trace must land on one instance, so in front of it there is a loadbalancing exporter keyed by trace ID;
  • centralized policy: PII redaction, dropping unneeded attributes, routing and quotas per team;
  • switching the backend only changes the gateway configuration.

Must-haves for reliability: memory_limiter in every collector (as the first processor), batch, sending_queue and retry_on_failure on the exporters, and a persistent queue (file_storage) for important streams. You must also watch the collector's own metrics (otelcol_exporter_send_failed_*, otelcol_processor_refused_*, queue size); otherwise telemetry silently disappears and you find out during an incident.

The trade-off: every extra hop adds latency, cost and one more point of failure. In a small system, sending straight from the agent to the backend without a gateway may be enough.