

# Send profiles to CloudWatch

After your profiler produces OTLP profile data, send it to the CloudWatch profiles endpoint in one of the following ways. Profilers that don't sign their requests, such as async-profiler, must send through the CloudWatch agent or an OpenTelemetry Collector. For instructions on producing the profile data, see [Profile your application](CloudWatch-Profiles-publish-generate.md).

## Use the CloudWatch agent
<a name="CloudWatch-Profiles-publish-agent-config"></a>

You can send profiles to CloudWatch through the CloudWatch agent version 1.300075.0 and later. The agent sends the profile data that it receives on its OTLP endpoint to CloudWatch. It signs the data with its IAM role. The OTLP endpoint is off by default, so turn it on with the `otlp` source under `opentelemetry.collect`. For more information, see [Send OpenTelemetry data using the agent configuration file](CloudWatch-OTLPCloudWatchAgent.md#CloudWatch-OTLPCloudWatchAgent-ConfigFile). If you omit `grpc_endpoint` and `http_endpoint`, the agent listens on `127.0.0.1` only. Then only processes in the same network namespace can reach it. Keep that default when your profiler runs in the same network namespace as the agent. If you set the agent to listen on other addresses, restrict access with network controls such as security groups, host firewalls, or Kubernetes network policies. Profiles need no other setting, and the agent turns on the Collector profiles feature gate for you. When you turn on profiling with the CloudWatch Observability EKS add-on or the Helm chart, they turn on the OTLP endpoint for you. For more information, see [Use the EKS add-on or Helm chart](#CloudWatch-Profiles-publish-eks-addon).

## Use an OpenTelemetry Collector
<a name="CloudWatch-Profiles-publish-collector"></a>

The OpenTelemetry Collector keeps profiles support behind a feature gate, because the support is still in development. A feature gate turns on a Collector feature that is still in development. Without the profiles feature gate, the Collector doesn't accept a `profiles` pipeline. The CloudWatch agent turns on this gate for you.

To send profiles to CloudWatch through an OpenTelemetry Collector, do the following:

1. Start the Collector with the `--feature-gates=+service.profilesSupport` command line option.

1. Set `profiles_endpoint` of the `otlp_http` exporter to the CloudWatch profiles endpoint.

1. Authenticate your requests. For more information, see [Send directly to the endpoint](#CloudWatch-Profiles-publish-direct). To sign with SigV4, the Collector distribution must include a SigV4 authenticator extension.

For everything else, see the [OpenTelemetry Collector documentation](https://opentelemetry.io/docs/collector/) on the OpenTelemetry website.

## Send directly to the endpoint
<a name="CloudWatch-Profiles-publish-direct"></a>

A client can send OTLP/HTTP profile data directly to the endpoint in [Direct OTLP ingestion endpoint](CloudWatch-Profiles-publish.md#CloudWatch-Profiles-publish-endpoint). Sign each request with AWS Signature Version 4 (SigV4) using the signing service name `monitoring`, or send a CloudWatch API key as a bearer token. For API keys, see [Setting up bearer token authentication for metrics and profiles](CloudWatch-OTLP-MetricsBearerTokenAuth.md). When you use temporary credentials, include the session token in the `x-amz-security-token` header.

## Use the EKS add-on or Helm chart
<a name="CloudWatch-Profiles-publish-eks-addon"></a>

On Kubernetes, you can use the CloudWatch Observability EKS add-on (version `v8.0.1-eksbuild.1` or later) or the `amazon-cloudwatch-observability` Helm chart (version `8.0.0` or later). They turn on the profiler for your Java workloads and send its profiles to CloudWatch. When you set `manager.autoInstrumentationConfiguration.java.profiling.enabled` to the string `"true"`, the operator turns on the ADOT Java agent profiler in new pods. It points the profiler at the CloudWatch agent on the same node. Restart your workloads after you change the setting. For setup steps and considerations, see [Profile Java workloads on Kubernetes](CloudWatch-Profiles-getting-started-kubernetes.md). For more information about the add-on, see [OTel Container Insights (Recommended)](container-insights-eks-otel.md).