Receive OTLP data
The otlp source receives metrics, traces, and logs sent to the agent over
the OpenTelemetry Protocol (OTLP), and forwards them to the CloudWatch OTLP endpoints. The agent
sends logs that it receives to the /aws/cwagent/otlp log group, in a log stream
named after the host identifier and the service.name resource attribute, unless
the logs set the aws.log.group.name and aws.log.stream.name
resource attributes. This source can include the following fields:
-
grpc_endpoint– Optional. Specifies the address the agent uses to listen for OTLP data sent using gRPC. The format isip:port. This address must match the address set for the gRPC exporter in the OpenTelemetry SDK. If you omit this field, the agent uses the default127.0.0.1:4317. In a containerized deployment, set this to0.0.0.0:4317so the agent accepts traffic from other pods. The receiver doesn't authenticate senders, so restrict access to the port with security groups or network policies. -
http_endpoint– Optional. Specifies the address the agent uses to listen for OTLP data sent over HTTP. The format isip:port. This address must match the address set for the HTTP exporter in the OpenTelemetry SDK. If you omit this field, the agent uses the default127.0.0.1:4318. In a containerized deployment, set this to0.0.0.0:4318so the agent accepts traffic from other pods. The receiver doesn't authenticate senders, so restrict access to the port with security groups or network policies. -
span_metrics_enabled– Optional. Iftrue, the agent derives request, error, and duration metrics from received traces. The default value isfalse. The default OpenTelemetry configuration (default:otel) sets it totrue.
Applications instrumented with an OpenTelemetry SDK can send metrics, logs, and traces to the agent, which forwards them to the CloudWatch OTLP endpoints. The agent signs the requests, so the application doesn't need Amazon credentials.
-
Add an
otlpsource to theopentelemetrysection. To also generate request, error, and duration metrics from the traces that the agent receives, setspan_metrics_enabledtotrue.{ "opentelemetry": { "collect": { "host_metrics": {}, "otlp": { "span_metrics_enabled": true } } } } -
Configure the application's OpenTelemetry SDK to export to the agent. The following standard environment variables work with the SDKs for most languages:
export OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318 export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf export OTEL_SERVICE_NAME=my-serviceexport OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=productionTo send over gRPC instead, set the endpoint to
http://127.0.0.1:4317and the protocol togrpc. -
Start the agent, and then query the application's metrics in Query Studio by service name:
{"my_metric", "@resource.service.name"="my-service"}To view traces, use Transaction Search. Traces require Transaction Search to be enabled.
Application logs go to the
/aws/cwagent/otlplog group, in a log stream named. To use a different log group or stream, set thehost-id/my-serviceaws.log.group.nameandaws.log.stream.nameresource attributes, for example inOTEL_RESOURCE_ATTRIBUTES.
If the application runs in a container or on another host, set the agent's
grpc_endpoint to 0.0.0.0:4317 and http_endpoint to
0.0.0.0:4318, and restrict access to the ports with security groups or network
policies, as described for the otlp fields earlier in this topic. For SDK setup
by language, see Example: send application metrics through the CloudWatch agent.