OpenTelemetry Collection: Match the Collector to the Workload
BuildGuide11 min read

OpenTelemetry Collection: Match the Collector to the Workload

By Nicolas Narbais

Stop forcing every cloud workload into the same OpenTelemetry Collector topology. Match collection to the runtime across AWS, GCP, and Azure, preserve origin context, and add a gateway only when it earns it's worth it.

Last updated on

A platform team builds a clean OpenTelemetry Collector setup on Kubernetes, sees traces and metrics flowing, and tries to stamp that exact same architecture across the rest of the company.

Then reality shows up.

Half of production still runs on EC2 or Compute Engine VMs. One team ships on ECS Fargate, another on Cloud Run, a third on Azure Functions. Databases live on RDS and Cloud SQL where you cannot install an agent at all. There is no longer a single solution for everyone.

Another issue, picture ten equally loaded VMs running your payment service. Your dashboard shows a 10% error rate. That single number hides two completely different incidents: either every VM is throwing errors on 10% of requests, or nine VMs are healthy and one box is failing 100% of its traffic. If your collection layer loses host.id or service.instance.id, you cannot tell those two situations apart, and you cannot correlate the spike with local CPU, memory, or logs.

Note

If you only remember one sentence: Collect as close to the source as practical, standardize your OpenTelemetry attribute contract across clouds instead of forcing one deployment topology, and add a centralized gateway only when it solves a concrete problem.

Separate three decisions teams keep conflating

To get started, start asking yourself 3 questions:

  1. Where is telemetry collected and enriched? (close to the workload, from a cloud API, or via an SDK)
  2. Where is it processed? (filtered, redacted, sampled, routed, and buffered)
  3. How is the collection pipeline operated? (Helm, Operator, systemd, fleet automation, credentials, upgrades)

Keeping those three questions independent stops you from building a gateway just because you want cleaner credential management, or deploying sidecars everywhere just because one serverless service needed one.

flowchart TD A["Applications, SDKs, and infrastructure"] --> B["Local collection and enrichment"] B --> C["Optional centralized processing"] B --> D["Observability backend"] C --> D

Regardless of where you run, every collection pipeline still has to cover four jobs:

  • Collection: receive application OTLP, tail local log files, scrape metrics, and query infrastructure or cloud APIs.
  • Contextualization: attach the identity of the service, instance, host, pod, container, task, cloud, and environment.
  • Processing and delivery: filter noise, redact sensitive data, sample, route, batch, buffer, and export reliably.
  • Standardization: emit consistent OpenTelemetry semantic conventions across clouds so an engineer debugging checkout does not care whether it runs on EKS or Cloud Run.

What actually dictates the collection pattern? The execution environment. So check the list below to see different situations for every cloud provider.

EnvironmentAWSGoogle CloudAzure
Managed KubernetesEKSGKEAKS
Virtual machinesEC2Compute Engine (GCE)Azure VMs
Containers with host accessECS on EC2Docker on GCEDocker on Azure VMs
Serverless containersECS FargateCloud RunAzure Container Apps
Serverless functionsLambdaCloud Run functionsAzure Functions
Managed databasesRDS / AuroraCloud SQL / AlloyDBAzure SQL / PostgreSQL
Restricted KubernetesEKS FargateGKE AutopilotAKS virtual nodes
Native monitoringCloudWatchCloud MonitoringAzure Monitor
Native logsCloudWatch LogsCloud LoggingAzure Monitor Logs
Streaming / deliveryKinesis / FirehosePub/SubEvent Hubs
Object storageS3Cloud StorageBlob Storage

These are conceptual parallels, not feature equivalents. The operational rule is what matters: once you know whether you have host access, container-runtime access, or only an API boundary, the right Collector architecture is easy to select.

Match the collection pattern to the workload

Let’s go through those execution environments.

1. Kubernetes: DaemonSet plus a cluster-level Deployment

Applies to: EKS with EC2 nodes, GKE Standard, AKS with conventional nodes, OpenShift, and self-managed Kubernetes.

On standard Kubernetes, split collection by where the signal lives:

  • Node-level DaemonSet: one Collector per eligible node handling filelog, kubeletstats, hostmetrics where needed, local OTLP reception, k8sattributes, and cloud resource detection.
  • Cluster-level Deployment: a separate Collector pulling cluster-wide API state—events, deployment status, pod phases, and node conditions—via k8s_cluster and k8sobjects.
flowchart TD subgraph K["Kubernetes cluster"] subgraph N1["Node 1"] P1["Application pods"] -->|OTLP| D1["DaemonSet Collector"] H1["Host, kubelet, container logs"] --> D1 end subgraph N2["Node 2"] P2["Application pods"] -->|OTLP| D2["DaemonSet Collector"] H2["Host, kubelet, container logs"] --> D2 end API["Kubernetes API"] --> C["Cluster Collector: Deployment"] end D1 --> B["Observability backend"] D2 --> B C --> B

That cluster Collector is not a gateway. It owns a distinct collection responsibility. If you want the exact Helm values, RBAC, and identity checks for this baseline, read OpenTelemetry on Kubernetes: deploy node, cluster, and identity in that order and extending Kubernetes enrichment with your own labels and annotations.

Three common mistakes:

  1. A DaemonSet does not guarantee node-local routing. Sending OTLP to a regular Kubernetes Service hops across nodes and breaks k8sattributes association or wastes cross-AZ bandwidth. Route via the node IP or a Service with internalTrafficPolicy: Local (accounting for brief unavailability during DaemonSet rollouts).
  2. Cluster receivers duplicate data if you scale replicas blindly. Run one active cluster Collector or use leader election/coordination. For Prometheus scraping, assign each target once using the Target Allocator or explicit sharding.
  3. Helm vs. the OpenTelemetry Operator is an operational scope choice, not a maturity badge. Use the OpenTelemetry Helm chart for straightforward Collector deployments. Go for the OpenTelemetry Operator when you genuinely need continuous CRD reconciliation, built-in auto-instrumentation injection, managed sidecar injection, or an integrated Prometheus Target Allocator—accepting the extra controller, CRDs, and webhooks that come with it.

Some special cases:

Restricted environmentCollection implication
EKS FargateDaemonSets are not supported; use sidecars, SDK export, and native cloud integrations.
GKE AutopilotDaemonSets are possible, but host mounts and privileges are restricted (GKE Autopilot security).
AKS virtual nodesDaemonSets do not run on virtual nodes; use workload-level or remote collection.

2. Virtual machines and bare metal: a local Collector service

Applies to: AWS EC2, Google Compute Engine, Azure VMs, and on-premises Linux or Windows hosts.

Run the Collector as a system service (systemd on Linux, Windows Service on Windows) right on the host. It collects local log files, host metrics, and localhost OTLP from applications, then enriches everything using the matching cloud resource detector (ec2, gcp, or azure) so host.id, host.name, os.type, cloud.provider, cloud.region, and cloud.availability_zone are always attached.

flowchart TD subgraph V1["VM 1"] A1["Applications"] --> C1["Local OTel Collector"] H1["Host metrics and log files"] --> C1 end subgraph V2["VM 2"] A2["Applications"] --> C2["Local OTel Collector"] H2["Host metrics and log files"] --> C2 end C1 --> B["Observability backend"] C2 --> B

The upside is complete host-to-application correlation, local filtering and buffering, and support for legacy services that only write to files. The cost is fleet lifecycle management: you now have a Collector to patch, configure, and supply credentials to across every VM.

Once you pass a handful of machines, automate rollout and upgrades through your existing image system, fleet management, Ansible, or an OpAMP control plane. Never edit configs by hand over SSH.

3. VM-based containers: a shared host Collector

Applies to: ECS on EC2, Docker on GCE or Azure VMs, Docker Compose, Nomad, and self-managed container hosts.

When you still control the underlying host, do not go for a sidecar per container since it will cost too much CPU and memory. Deploy one Collector per host—using the ECS DAEMON scheduling strategy on ECS on EC2, or an equivalent host service.

flowchart TD subgraph H["Container host"] A["Task or container A"] --> C["Host-level Collector"] B["Task or container B"] --> C R["Container runtime, host metrics, logs"] --> C end C --> O["Observability backend"]
Warning

Watch the metadata trap on ECS on EC2: The ECS task metadata endpoint returns metadata for the Collector’s own task, not for the application tasks sending telemetry to it. If you blindly enable task-level enrichment on a shared host Collector, you can overwrite application identity with the Collector’s identity. Preserve application-side resource attributes and pair them with host or runtime enrichment carefully.

4. Serverless containers: sidecar or direct remote OTLP

Applies to: ECS Fargate, Google Cloud Run, and Azure Container Apps.

Here the underlying host disappears. Stop trying to collect host metrics that do not exist and correlate at the task, service instance, revision, or replica level instead.

That leaves two viable shapes: a Collector sidecar inside the execution unit, or direct SDK export to a remote OTLP gateway or backend.

flowchart LR subgraph T["Task, instance, or replica"] A["Instrumented application"] -->|localhost OTLP| S["Collector sidecar"] end S --> B["Observability backend"] R["Application with resource attributes"] --> G["Remote Collector or gateway"] G --> B
AspectCollector sidecarSDK to remote OTLP
Application traces and metricsYesYes
Local processing and filteringYesLimited
Task infrastructure metricsWhere exposed locallyNative integration or separate path
Source identitySDK + local metadataSDK + platform metadata
Resource overheadPaid per execution unitLower local overhead
LifecycleCoupled to workloadIndependent remote Collector

Prefer one sidecar per execution unit (not per container) only when local processing, buffering, or task-level metrics justify the overhead. Otherwise, direct OTLP export from a well-configured SDK keeps the overall setup lean.

Cloud nuances matter here:

  • ECS Fargate: The awsecscontainermetrics receiver can pull task and container stats from the ECS metadata endpoint; container logs usually travel via FireLens or CloudWatch Logs.
  • Cloud Run: Sidecar background flushing can require CPU outside active HTTP requests (Cloud Run sidecars). Factor in instance-based billing, graceful shutdown behavior, and cost before adding a sidecar to spiky services.
  • Azure Container Apps: Check the managed environment-level OpenTelemetry agent before building custom sidecars, and validate its current scaling limits and health telemetry.
  • All three platforms: Test scale-to-zero, SIGTERM flushing, startup ordering, and duplicate collection paths before finalizing the architecture.

5. Serverless functions: extensions are not universal

Applies to: AWS Lambda, Google Cloud Run functions, and Azure Functions.

Teams coming from AWS often assume every serverless platform works like Lambda layers and extensions.

flowchart LR subgraph AWS["AWS Lambda"] L["Function + OTel instrumentation"] --> E["Collector extension"] end E --> B["Observability backend"] subgraph GCP["Cloud Run functions"] G["Function + SDK"] end subgraph AZ["Azure Functions"] A["Functions host + instrumented worker"] end G --> R["Optional remote OTLP gateway"] A --> R R --> B N["Cloud-native platform logs and metrics"] --> I["Native integration"] I --> B
PlatformPreferred starting point
AWS LambdaOpenTelemetry Lambda instrumentation layer + Collector extension, or direct SDK export to a remote OTLP endpoint
Google Cloud Run functionsInstrumentation SDK exporting to remote OTLP, paired with native platform telemetry
Azure FunctionsNative OpenTelemetry host output plus supported language-worker instrumentation

On Azure Functions, a supported runtime can enable OpenTelemetry output directly in host.json:

{
  "version": "2.0",
  "telemetryMode": "OpenTelemetry"
}

Across all three clouds, serverless collection lives or dies on cold-start impact, execution freeze/thaw semantics, flush timeouts, and invocation identity. A local Lambda extension buys you decoupled delivery and local processing at the cost of extra memory and runtime constraints; remote OTLP export keeps the function lighter but puts network latency and flush deadlines directly on the invocation path.

6. Managed services: combine APIs, streaming, and remote receivers

Applies to: RDS/Aurora, Cloud SQL/AlloyDB, Azure SQL/PostgreSQL, managed Kafka, queues, and object storage.

You cannot install an agent on a managed database. You pull signals through three complementary mechanisms:

flowchart TD A["AWS managed services"] --> AW["CloudWatch / CloudWatch Logs"] G["GCP managed services"] --> GC["Cloud Monitoring / Cloud Logging"] Z["Azure managed services"] --> AZ["Azure Monitor"] AW -->|API or Firehose as supported| I["Integration or Collector"] GC -->|API or Pub/Sub as supported| I AZ -->|API or Event Hubs as supported| I D["Database or service endpoint"] -->|Direct protocol / remote receiver| I I --> B["Observability backend"]
MechanismStrengthsTradeoffs
Cloud API pollingSimple, centralized setupAPI quotas, polling lag, request costs
Cloud streaming (Firehose, Pub/Sub, Event Hubs)Continuous delivery, scales wellExtra cloud infrastructure and delivery charges
Direct remote receiverDeep service-specific telemetryNetwork reachability, DB credentials, single-owner scheduling

These mechanisms complement each other. A managed PostgreSQL instance can give you host CPU, storage, and IOPS from CloudWatch or Cloud Monitoring while a dedicated Collector running the PostgreSQL receiver pulls connection, lock, and query behavior directly from the engine (see collecting PostgreSQL signals with OpenTelemetry for how to stage that without over-privileging the database). Just make sure you do not collect the exact same metric through both paths, and verify which cloud signals actually support streaming (not every cloud metric or log stream uses the same transport).

Do you actually need a gateway?

Now for the question that bloats more Collector diagrams than anything else: when should local Collectors export straight to the backend, and when should you put a gateway pool in the middle?

Direct export from local Collectors should be your default. Every gateway tier adds a network hop, compute and cross-AZ transfer costs, another failure domain, and another stateful or semi-stateful fleet to upgrade.

flowchart TD K["Kubernetes local Collectors"] --> G["Gateway pool"] V["VM local Collectors"] --> G S["Serverless sidecars or SDKs"] --> G G --> B["Observability backend"]

Introduce a gateway only when you can point to a concrete requirement it satisfies:

  • Tail-based sampling, which requires seeing all spans of a trace in one place.
  • Centralized backend credentials so tokens are not scattered across dozens of clusters and VM fleets.
  • Controlled outbound egress (PrivateLink, Private Service Connect, Private Link, or strict firewall rules).
  • Organization-wide routing and governance, including dual-export during a backend migration.
  • Dedicated buffering to isolate backend outages from constrained workloads.

You can also run a central Collector with no local agents? That is reasonable when local installation is impossible (serverless workloads, restricted runtimes) or for application-only telemetry where SDKs reliably attach every required resource attribute. Just remember two constraints: a remote gateway cannot read local log files or host metrics, and it must never overwrite the origin’s resource attributes with its own host or pod identity.

And when traffic crosses from local Collectors to a gateway, treat that hop as an explicit security boundary—TLS, admission control, and sender identity are covered in Collector to Collector: choose authentication for the hop you have.

Once you do have both tiers, put each processing step at the lowest layer that has enough context to do it accurately:

OperationLocal CollectorGateway
Host metadata enrichmentPreferredAvoid (do not stamp gateway identity)
Kubernetes enrichmentPreferredPossible with reliable pod association
Sensitive data redactionPreferredUseful as a second safeguard
Drop obvious noise (debug logs, health checks)PreferredPossible
Probabilistic trace samplingPreferred earlyPossible
Tail-based trace samplingUsually unsuitablePreferred
Shared routing and org-level policyPossiblePreferred when justified
Cross-source metric aggregationLimitedPossible with correct routing and semantics
Buffering and retriesRecommendedRecommended

Do not deploy a gateway solely to drop noise you could filter at the source. And before you strip a metric dimension to save money, test what happens to the remaining series: removing an attribute can merge distinct time series, require reaggregation, or wipe out the exact dimension you need during an incident. Evaluate bytes saved against investigative value, not cardinality in isolation.

Putting it together: the architecture decision tree

When a new service or cloud account lands on your desk, walk it through this tree instead of copying the last team’s YAML:

flowchart TD A{"Workload type?"} A -->|Kubernetes with node access| K["DaemonSet + cluster Collector"] A -->|VM or bare metal| V["Host-level Collector"] A -->|Containers with host access| C["Shared host Collector"] A -->|Serverless containers or restricted nodes| S["Sidecar or remote OTLP"] A -->|Serverless functions| F["SDK, extension, or remote OTLP"] A -->|Managed services| M["API, streaming, or remote receiver"] K --> D V --> D C --> D S --> D F --> D M --> D D{"Need tail sampling, routing, shared policies, or network isolation?"} D -->|No| E["Direct export to backend"] D -->|Yes| G["Introduce appropriately scoped gateway"] G --> H{"Stateful processing?"} H -->|Yes| I["Trace-ID routing and stateful sizing"] H -->|No| J["Stateless horizontal scaling"] E --> R["Validate resilience, monitoring, and security"] I --> R J --> R

Before you call a collection architecture production-ready

Before rolling out a new Collector topolog verify these eight items in staging (you can test pipeline routing, enrichment, and failure modes locally first using a Docker Compose Collector lab):

  • Every workload type and signal has one explicit collection path, with no duplicate collection from overlapping receivers or native cloud integrations.
  • Telemetry retains service.name, service.instance.id, deployment.environment.name, and infrastructure identity across clouds, and cross-signal correlation is tested.
  • Node-local OTLP routes, network policies, TLS, workload identities, and least-privilege permissions are verified end to end.
  • Peak-load and backend-outage tests establish real queue sizing, retry windows, and loss behavior instead of guesses.
  • Collector health dashboards, delivery alerts, and an independent end-to-end freshness canary are active.
  • Tail sampling—if used—has trace-ID aware routing and generates RED metrics from unsampled data.
  • Configuration overlays, pinned Collector versions, canary rollouts, and rollback procedures are documented.
  • Native cloud integration costs (CloudWatch/Firehose, Pub/Sub, Event Hubs, cross-AZ transfer) are measured alongside backend ingestion volume.

Start with the simplest topology that gives you complete, well-attributed coverage for each runtime. Standardize the telemetry contract across AWS, GCP, and Azure and make every gateway tier justify its operational cost before you add it to the diagram.

Written by

Nicolas Narbais

Nicolas Narbais builds, breaks, debugs, and scales observability systems using OpenTelemetry and modern telemetry pipelines. He shares practical, opinionated lessons to help engineers get better signal with less noise.

Olatuak Editorial Philosophy

Better signal, not more telemetry.

Olatuak helps platform engineers, SREs, and observability teams turn noisy telemetry into clear operational decisions without blindly collecting more data.