Multi-Cloud OpenTelemetry Collection: Match the Collector to the Workload
BuildGuide10 min read

Multi-Cloud 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 its operational cost.

Last updated on

A platform team builds a clean OpenTelemetry Collector setup on Kubernetes and tries to stamp that exact topology across the rest of the company.

Then reality hits: EC2 and Compute Engine VMs, ECS Fargate, Cloud Run, Azure Functions, and managed databases like RDS and Cloud SQL where no agent can run. Worse, picture ten equally loaded VMs serving payments with a 10% error rate. Either every VM fails 10% of traffic, or one box fails 100%. Lose host.id or service.instance.id in your collection tier, and you cannot tell the two incidents apart.

Note

Core rule: Collect as close to the source as the runtime allows, standardize one OpenTelemetry attribute contract across clouds instead of forcing one topology, and add a gateway only when it solves a concrete problem.

Separate three architecture decisions teams conflate

Keep three questions independent so credential policy never forces unnecessary gateways and one serverless app never forces sidecars everywhere:

  1. Collection and enrichment: close to the workload, from a cloud API, or from an SDK?
  2. Processing: where do filtering, redaction, sampling, routing, and buffering run?
  3. Fleet operations: how are upgrades, secrets, and configs shipped (Helm, Operator, systemd, OpAMP)?
flowchart TD A["Applications, SDKs, and infrastructure"] --> B["Local collection and enrichment"] B --> C["Optional centralized processing"] B --> D["Observability backend"] C --> D

Every pipeline still owns four jobs: collection (OTLP, files, metrics, cloud APIs), contextualization (service, instance, host/pod, cloud, environment), processing/delivery (filter, redact, sample, buffer, retry), and standardization (consistent semantic conventions across clouds).

Your execution environment dictates the topology:

Runtime boundaryAWSGoogle 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 monitoring / logsCloudWatch / CW LogsCloud Monitoring / LoggingAzure Monitor / Logs
Streaming / object storageKinesis / Firehose, S3Pub/Sub, Cloud StorageEvent Hubs, Blob Storage

These are conceptual parallels, not feature equivalents. Once you know whether you have host access, container-runtime access, or only an API boundary, the right pattern follows immediately.

Six workload patterns across AWS, GCP, and Azure

1. Kubernetes: DaemonSet plus a single active cluster Deployment

Applies to: EKS (EC2 nodes), GKE Standard, AKS (standard nodes), OpenShift, and self-managed clusters.

Split collection by signal locality:

  • Node DaemonSet: handles filelog, kubeletstats, optional hostmetrics, local OTLP, k8sattributes, and cloud resource detection.
  • Cluster Deployment: pulls cluster-wide API state (events, deployments, pod phases, 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

For exact Helm values, RBAC, and identity checks, see OpenTelemetry on Kubernetes and extending Kubernetes enrichment with labels and annotations. Avoid three traps:

  1. DaemonSet ≠ node-local traffic: a normal Kubernetes Service routes OTLP across nodes, breaking k8sattributes association and adding cross-AZ charges. Target the node IP or use internalTrafficPolicy: Local (planning for brief gaps during rollouts).
  2. Unshaded cluster replicas duplicate data: keep one active cluster Collector (or leader election), and use Target Allocator or explicit sharding for Prometheus scrapes.
  3. Helm vs Operator is a scope choice: use the Helm chart for standard Collector fleets; adopt the OpenTelemetry Operator when you need CRD reconciliation, auto-instrumentation injection, managed sidecars, or Target Allocator.
Restricted KubernetesCollection adjustment
EKS FargateNo DaemonSets; use sidecars, SDK export, and native cloud integrations
GKE AutopilotDaemonSets supported with host-mount/privilege limits (Autopilot security)
AKS virtual nodesNo DaemonSets; use workload-level or remote collection

2. Virtual machines and bare metal: local host service

Applies to: EC2, GCE, Azure VMs, and on-premises Linux/Windows hosts.

Run one Collector per host (systemd or Windows Service) to collect local log files, host metrics, and localhost OTLP. Enable the matching cloud resource detector (ec2, gcp, or azure) so host.id, host.name, os.type, cloud.provider, cloud.region, and cloud.availability_zone attach automatically.

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

You get full host-to-app correlation and local buffering at the cost of fleet lifecycle work. Automate rollouts through base images, Ansible, or OpAMP once you pass a handful of machines. Never patch configs over SSH.

3. VM-based containers: one shared Collector per host

Applies to: ECS on EC2, Docker on GCE/Azure VMs, Docker Compose, and Nomad.

When you own the host, avoid paying sidecar CPU/memory on every container. Deploy one Collector per host (for example via ECS DAEMON scheduling).

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

ECS on EC2 metadata trap: The ECS task metadata endpoint returns metadata for the Collector’s own task, not the calling app tasks. Do not let a shared host Collector overwrite application resource attributes with its own task identity.

4. Serverless containers: sidecar or direct remote OTLP

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

With no host underneath, correlate at the task, revision, or replica level using either one sidecar per execution unit or direct SDK export to a remote OTLP endpoint:

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 sidecarDirect SDK to remote OTLP
Traces and metricsYesYes
Local filtering / bufferingYesLimited
Task infrastructure metricsLocal metadata endpointNative integration / separate path
OverheadPaid per execution unitLower per-unit footprint
LifecycleCoupled to workloadIndependent remote fleet

Pick a sidecar only when local buffering, processing, or task-level metrics justify its memory and lifecycle cost:

  • ECS Fargate: awsecscontainermetrics reads local task stats; container logs normally move through FireLens or CloudWatch Logs.
  • Cloud Run: background flushing in sidecars can need CPU outside active requests (Cloud Run sidecars); check instance-based billing and graceful shutdown.
  • Azure Container Apps: evaluate the managed environment-level OTel agent before maintaining custom sidecars.
  • All three: verify scale-to-zero, SIGTERM flushing, startup ordering, and duplicate log paths before shipping.

5. Serverless functions: match the cloud’s native execution model

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

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
PlatformRecommended starting point
AWS LambdaOpenTelemetry Lambda layer + Collector extension, or direct remote OTLP
Google Cloud Run functionsInstrumentation SDK to remote OTLP + native platform telemetry
Azure FunctionsNative OpenTelemetry host output + language worker SDK

On supported Azure Functions runtimes, enable OpenTelemetry output directly in host.json:

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

Test cold-start overhead, freeze/thaw behavior, and flush timeouts on all three clouds. A Lambda extension decouples export from handler latency at the cost of extra memory; direct OTLP keeps functions lighter but puts network flush time on the invocation path.

6. Managed services: combine cloud APIs, streams, and remote receivers

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

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| I["Integration or Collector"] GC -->|API or Pub/Sub| I AZ -->|API or Event Hubs| I D["Database or service endpoint"] -->|Remote receiver| I I --> B["Observability backend"]
MechanismBest forTradeoff
Cloud API pollingSimple centralized setupAPI quotas, lag, request cost
Cloud streaming (Firehose, Pub/Sub, Event Hubs)High-volume continuous deliveryExtra cloud services and delivery fees
Direct remote receiverEngine internals (locks, queries, connections)Network access, DB credentials, single-owner scheduling

Combine them without overlapping metrics. For instance, pull host CPU/IOPS from CloudWatch or Cloud Monitoring while a single Collector runs the PostgreSQL receiver for locks and queries (see PostgreSQL with OpenTelemetry).

Add a gateway only when it earns its operational cost

Direct export from local Collectors should be your default. Every gateway tier adds compute, cross-AZ transfer cost, a network hop, and another 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 for a concrete requirement:

  • Tail-based sampling needing every span of a trace in one place.
  • Centralized backend credentials so secrets stay off dozens of clusters and VM fleets.
  • Controlled outbound egress (PrivateLink, Private Service Connect, strict firewalls).
  • Org-wide routing or dual-export during backend migrations.
  • Dedicated outage buffering offloaded from resource-constrained workloads.

A central Collector without local agents works when local agents cannot run (serverless, restricted runtimes) or for app-only OTLP where SDKs attach all identity, provided the gateway never overwrites origin identity and you accept it cannot read local log files or host metrics. Treat every agent-to-gateway hop as an explicit security boundary (Collector-to-Collector authentication).

When you run both tiers, place every operation at the lowest layer with enough context:

OperationLocal CollectorGateway
Host metadata enrichmentPreferredAvoid (never stamp gateway host)
Kubernetes enrichmentPreferredOnly with reliable pod association
Sensitive-data redactionPreferredSecond safeguard
Drop noise (debug logs, health checks)PreferredFallback
Probabilistic trace samplingPreferred earlyFallback
Tail-based trace samplingUnsuitablePreferred
Shared routing and org policyLimitedPreferred when justified
Cross-source metric aggregationLimitedOnly with stateful routing
Buffering and retriesRecommendedRecommended

Before dropping a metric attribute to cut volume, check whether removing it merges distinct time series or removes the dimension on-call needs. Measure bytes saved against investigative value, not cardinality alone.

Where multi-cloud architectures break in production

Staging proves connectivity. Production breaks in three places: trace sampling, cross-cloud governance, and outage recovery.

Trace sampling without lying to your dashboards

Compare the four OpenTelemetry sampling options:

StrategyDecision pointStrengthLimitation
No samplingKeep allComplete trace coverageHighest transport and ingest cost
SDK head samplingAt trace creationSaves CPU, serialization, networkBlind to errors/slow tails; inaccurate span metrics
Collector probabilisticAfter generationStateless, cuts backend volumeApps/agents pay full cost; drops errors equally
Tail-based samplingAfter decision windowKeeps errors, slow tails, key flowsStateful, memory-heavy, needs trace-ID routing

Two rules prevent sampling from corrupting operations:

  1. Tail sampling requires trace-ID routing: A plain L4/L7 load balancer splits one trace across replicas. Route by trace ID via the loadbalancing exporter ahead of tailsampling, size memory for peak trace rate × decision window, and plan for late spans, rolling restarts, and cross-region traces.
  2. Never compute service SLOs from tail-sampled traces: Keeping 100% of errors and 5% of successes inflates error rates wildly. Generate RED metrics from unsampled spans before tail sampling.
flowchart TD A["Unsampled spans"] --> M["Generate RED metrics"] A --> S["Trace sampling"] M --> B["Accurate service dashboards and SLOs"] S --> C["Sampled traces for investigation"]

Keep processing regional; standardize the attribute contract globally

Run local Collectors and optional gateways per region or cloud. Shipping raw telemetry cross-region multiplies egress bills, widens blast radius, and complicates residency. What must be global is the mandatory attribute contract:

AttributeAWS exampleGCP exampleAzure example
cloud.providerawsgcpazure
cloud.account.idAWS account IDGCP project IDAzure subscription ID
cloud.regioneu-central-1europe-west3germanywestcentral
host.idEC2 instance IDGCE instance IDAzure VM ID
k8s.cluster.nameeks-prodgke-prodaks-prod
service.namecheckoutcheckoutcheckout
deployment.environment.nameproductionproductionproduction
service.version2.4.12.4.12.4.1

Pair these with service.namespace, service.instance.id, and ownership metadata while keeping high-cardinality fields off metric dimensions.

Separate delivery lag from ingestion lag, and size queues with math

flowchart LR A["Receiver"] --> P["Memory limiter / processors"] P --> Q["Exporter sending queue"] Q --> E["Retrying exporter"] E --> B["Backend"] D["Optional persistent storage"] --- Q

Use Collector internal telemetry plus an end-to-end timestamped canary to separate two distinct failures:

  • Delivery lag (before backend acceptance): sent throughput drops, otelcol_exporter_queue_size climbs toward otelcol_exporter_queue_capacity, and enqueue failures appear. Fix the Collector hop or network path.
  • Ingestion lag (after backend acceptance): Collector queues stay low and exports succeed, while canary emit-to-query latency rises. The bottleneck is backend indexing.

Size outage buffers explicitly instead of guessing (Collector resiliency). For a gateway receiving 10 MB/s through a 15-minute backend outage:

  • Buffer required: 10 MB/s × 900 s ≈ 9 GB, plus storage overhead and headroom.
  • Retry window: Must stay active for at least 15 minutes or batches expire before recovery.
  • Drain time: Exporting at 30 MB/s while ingesting 10 MB/s live traffic yields 20 MB/s net drain, taking roughly 7.5 minutes to clear the backlog plus backend indexing time.

Persistent queues protect batches already queued on surviving disk; they do not preserve in-flight processor or tail-sampling state (and DaemonSet filelog recovery still depends on persisted offsets and readable rotated files). For multi-hour replay, put a durable broker like Kafka in the path instead of stretching Collector queues.

Alert on export failures, queue ratio, memory-limiter refusals, and canary lag through an independent path so a broken Collector cannot silence its own page.

Architecture decision tree

Walk every new service or cloud account 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

Staging checklist before going to production

Verify these eight items in staging before rolling out a new Collector topology (you can rehearse pipeline routing and failure modes locally first with a Docker Compose Collector lab):

  • Every workload type and signal has one explicit collection path, with no overlap between receivers and native cloud integrations.
  • Telemetry retains service.name, service.instance.id, deployment.environment.name, and cloud/host identity, with cross-signal correlation tested.
  • Node-local OTLP routing, network policies, TLS, workload identity, and least-privilege permissions are verified end to end.
  • Peak-load and backend-outage tests validate real queue sizing, retry windows, and drop behavior.
  • Collector health dashboards, delivery alerts, and an independent freshness canary are active.
  • Tail sampling (if used) has trace-ID routing and computes RED metrics from unsampled spans.
  • Config overlays, pinned Collector versions, canary rollouts, and rollback steps are documented.
  • Native cloud integration costs (CloudWatch/Firehose, Pub/Sub, Event Hubs, cross-AZ transfer) are tracked alongside backend ingest.

Walk one active multi-cloud workload through the decision tree above today, remove any gateway tier that lacks a named policy job, and lock down the eight mandatory attributes across every runtime.

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.

Scroll to zoom · Drag to pan · Double-click to reset