
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.
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.
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:
- Collection and enrichment: close to the workload, from a cloud API, or from an SDK?
- Processing: where do filtering, redaction, sampling, routing, and buffering run?
- Fleet operations: how are upgrades, secrets, and configs shipped (Helm, Operator, systemd, OpAMP)?
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 boundary | AWS | Google Cloud | Azure |
|---|---|---|---|
| Managed Kubernetes | EKS | GKE | AKS |
| Virtual machines | EC2 | Compute Engine (GCE) | Azure VMs |
| Containers with host access | ECS on EC2 | Docker on GCE | Docker on Azure VMs |
| Serverless containers | ECS Fargate | Cloud Run | Azure Container Apps |
| Serverless functions | Lambda | Cloud Run functions | Azure Functions |
| Managed databases | RDS / Aurora | Cloud SQL / AlloyDB | Azure SQL / PostgreSQL |
| Restricted Kubernetes | EKS Fargate | GKE Autopilot | AKS virtual nodes |
| Native monitoring / logs | CloudWatch / CW Logs | Cloud Monitoring / Logging | Azure Monitor / Logs |
| Streaming / object storage | Kinesis / Firehose, S3 | Pub/Sub, Cloud Storage | Event 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, optionalhostmetrics, local OTLP,k8sattributes, and cloud resource detection. - Cluster Deployment: pulls cluster-wide API state (events, deployments, pod phases, node conditions) via
k8s_clusterandk8sobjects.
For exact Helm values, RBAC, and identity checks, see OpenTelemetry on Kubernetes and extending Kubernetes enrichment with labels and annotations. Avoid three traps:
- DaemonSet ≠ node-local traffic: a normal Kubernetes Service routes OTLP across nodes, breaking
k8sattributesassociation and adding cross-AZ charges. Target the node IP or useinternalTrafficPolicy: Local(planning for brief gaps during rollouts). - Unshaded cluster replicas duplicate data: keep one active cluster Collector (or leader election), and use Target Allocator or explicit sharding for Prometheus scrapes.
- 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 Kubernetes | Collection adjustment |
|---|---|
| EKS Fargate | No DaemonSets; use sidecars, SDK export, and native cloud integrations |
| GKE Autopilot | DaemonSets supported with host-mount/privilege limits (Autopilot security) |
| AKS virtual nodes | No 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.
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).
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:
| Aspect | Collector sidecar | Direct SDK to remote OTLP |
|---|---|---|
| Traces and metrics | Yes | Yes |
| Local filtering / buffering | Yes | Limited |
| Task infrastructure metrics | Local metadata endpoint | Native integration / separate path |
| Overhead | Paid per execution unit | Lower per-unit footprint |
| Lifecycle | Coupled to workload | Independent remote fleet |
Pick a sidecar only when local buffering, processing, or task-level metrics justify its memory and lifecycle cost:
- ECS Fargate:
awsecscontainermetricsreads 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,
SIGTERMflushing, 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.
| Platform | Recommended starting point |
|---|---|
| AWS Lambda | OpenTelemetry Lambda layer + Collector extension, or direct remote OTLP |
| Google Cloud Run functions | Instrumentation SDK to remote OTLP + native platform telemetry |
| Azure Functions | Native 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.
| Mechanism | Best for | Tradeoff |
|---|---|---|
| Cloud API polling | Simple centralized setup | API quotas, lag, request cost |
| Cloud streaming (Firehose, Pub/Sub, Event Hubs) | High-volume continuous delivery | Extra cloud services and delivery fees |
| Direct remote receiver | Engine 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.
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:
| Operation | Local Collector | Gateway |
|---|---|---|
| Host metadata enrichment | Preferred | Avoid (never stamp gateway host) |
| Kubernetes enrichment | Preferred | Only with reliable pod association |
| Sensitive-data redaction | Preferred | Second safeguard |
| Drop noise (debug logs, health checks) | Preferred | Fallback |
| Probabilistic trace sampling | Preferred early | Fallback |
| Tail-based trace sampling | Unsuitable | Preferred |
| Shared routing and org policy | Limited | Preferred when justified |
| Cross-source metric aggregation | Limited | Only with stateful routing |
| Buffering and retries | Recommended | Recommended |
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:
| Strategy | Decision point | Strength | Limitation |
|---|---|---|---|
| No sampling | Keep all | Complete trace coverage | Highest transport and ingest cost |
| SDK head sampling | At trace creation | Saves CPU, serialization, network | Blind to errors/slow tails; inaccurate span metrics |
| Collector probabilistic | After generation | Stateless, cuts backend volume | Apps/agents pay full cost; drops errors equally |
| Tail-based sampling | After decision window | Keeps errors, slow tails, key flows | Stateful, memory-heavy, needs trace-ID routing |
Two rules prevent sampling from corrupting operations:
- Tail sampling requires trace-ID routing: A plain L4/L7 load balancer splits one trace across replicas. Route by trace ID via the
loadbalancingexporter ahead oftailsampling, size memory forpeak trace rate × decision window, and plan for late spans, rolling restarts, and cross-region traces. - 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.
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:
| Attribute | AWS example | GCP example | Azure example |
|---|---|---|---|
cloud.provider | aws | gcp | azure |
cloud.account.id | AWS account ID | GCP project ID | Azure subscription ID |
cloud.region | eu-central-1 | europe-west3 | germanywestcentral |
host.id | EC2 instance ID | GCE instance ID | Azure VM ID |
k8s.cluster.name | eks-prod | gke-prod | aks-prod |
service.name | checkout | checkout | checkout |
deployment.environment.name | production | production | production |
service.version | 2.4.1 | 2.4.1 | 2.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
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_sizeclimbs towardotelcol_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/swhile ingesting10 MB/slive traffic yields20 MB/snet 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:
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.
