OpenTelemetry Collector
The OpenTelemetry Collector is an open source, vendor-agnostic agent that receives, processes, and exports telemetry data. It acts as a central pipeline between your applications and Amazon CloudWatch, collecting metrics, logs, and traces from multiple sources and sending them to CloudWatch using the OpenTelemetry Protocol (OTLP).
Using the OpenTelemetry Collector with CloudWatch provides the following benefits:
-
Collect telemetry from multiple applications and hosts through a single agent, reducing the number of connections to CloudWatch.
-
Process and filter telemetry before sending it to CloudWatch, including adding or removing attributes, batching data, and sampling traces.
-
Use the same collector configuration across Amazon, on-premises, and other cloud environments, providing a consistent telemetry pipeline regardless of where your applications run.
-
Send metrics to CloudWatch with rich labels that are available to query using the Prometheus Query Language (PromQL) in CloudWatch Query Studio.
Supported receivers
The OpenTelemetry Collector supports a wide range of receivers for ingesting telemetry data. You can use OpenTelemetry receivers such as the OTLP receiver for applications instrumented with OpenTelemetry SDKs, or Prometheus receivers to scrape metrics from existing Prometheus exporters. Common Prometheus receivers used with CloudWatch include:
-
Prometheus receiver, for scraping any Prometheus-compatible endpoint
-
Host Metrics receiver, for collecting system-level metrics from the host
-
Kubernetes Cluster receiver, for collecting cluster-level metrics from the Kubernetes API server
You can configure multiple receivers in a single collector, allowing you to collect
both OpenTelemetry and Prometheus metrics and send them to CloudWatch through the same
pipeline. For the full list of available receivers, see the OpenTelemetry Collector
repository
Getting started
Prerequisite – If using the OTLP endpoint for tracing, ensure that Transaction Search is enabled.
Steps:
-
Download the latest release of the OpenTelemetry Collector distribution. For more information, see the OpenTelemetry Collector releases
. -
Install the OpenTelemetry Collector on your host. The collector runs on any operating system and platform. For more information, see Install the Collector
. -
Configure Amazon credentials on your Amazon EC2 or on-premises host. The collector uses these credentials to authenticate with CloudWatch when sending telemetry data. See below for details.
-
Setup Amazon credentials for your Amazon EKS or Kubernetes clusters. The easiest way to get started with Amazon EKS is to use the EKS OTel Container Insights add-on. If you prefer to use the OpenTelemetry Collector directly, follow the procedure below to set up Amazon credentials for your Amazon EKS or Kubernetes clusters to send telemetry to CloudWatch.
-
Configure the OTLP exporter in your collector configuration to send telemetry to the CloudWatch endpoint. See examples below.
Collector configuration examples
Copy and paste the content below to configure your collector to send logs and traces to the OTLP endpoints.
receivers: otlp: protocols: grpc: endpoint: 0.0.0.0:4317 http: endpoint: 0.0.0.0:4318 exporters: otlphttp/logs: compression: gzip logs_endpoint:logs_otlp_endpointheaders: x-aws-log-group: ency_log_group x-aws-log-stream: default auth: authenticator: sigv4auth/logs otlphttp/traces: compression: gzip traces_endpoint:traces_otlp_endpointauth: authenticator: sigv4auth/traces extensions: sigv4auth/logs: region: "region" service: "logs" sigv4auth/traces: region: "region" service: "xray" service: telemetry: extensions: [sigv4auth/logs, sigv4auth/traces] pipelines: logs: receivers: [otlp] exporters: [otlphttp/logs] traces: receivers: [otlp] exporters: [otlphttp/traces]
The following is an example to send logs and traces using sigv4 to us-east-1.
receivers: otlp: protocols: grpc: endpoint: 0.0.0.0:4317 http: endpoint: 0.0.0.0:4318 exporters: otlphttp/logs: compression: gzip logs_endpoint: https://logs.us-east-1.amazonaws.com/v1/logs headers: x-aws-log-group: MyApplicationLogs x-aws-log-stream: default auth: authenticator: sigv4auth/logs otlphttp/traces: compression: gzip traces_endpoint: https://xray.us-east-1.amazonaws.com/v1/traces auth: authenticator: sigv4auth/traces extensions: sigv4auth/logs: region: "us-east-1" service: "logs" sigv4auth/traces: region: "us-east-1" service: "xray" service: telemetry: extensions: [sigv4auth/logs, sigv4auth/traces] pipelines: logs: receivers: [otlp] exporters: [otlphttp/logs] traces: receivers: [otlp] exporters: [otlphttp/traces]
Note
Configure your OpenTelemetry SDKs to always_on sampling configuration to reliably record 100% spans and get full visibility into your critical applications with CloudWatch Application Signals. For more information, see an OpenTelemetry Java SDK sampler configuration
Copy and paste the content below to configure your collector to send metrics to the OTLP endpoints.
receivers: otlp: protocols: http: endpoint: "0.0.0.0:4318" processors: batch: send_batch_size: 200 timeout: 10s exporters: otlphttp: tls: insecure: false endpoint:metrics_otlp_endpointauth: authenticator: sigv4auth extensions: sigv4auth: service: "monitoring" region: "region" service: extensions: [sigv4auth] pipelines: metrics: receivers: [otlp] processors: [batch] exporters: [otlphttp]
The following is an example to send metrics using sigv4 to us-east-1.
receivers: otlp: protocols: http: endpoint: "0.0.0.0:4318" processors: batch: send_batch_size: 200 timeout: 10s exporters: otlphttp: tls: insecure: false endpoint: "https://monitoring.us-east-1.amazonaws.com/v1/metrics:443" auth: authenticator: sigv4auth extensions: sigv4auth: service: "monitoring" region: "us-east-1" service: extensions: [sigv4auth] pipelines: metrics: receivers: [otlp] processors: [batch] exporters: [otlphttp]