Publish profile data to Amazon CloudWatch
This page describes how ingestion works, the endpoint, the supported profile format version, and the permissions that you need. To produce profile data in your application, see Profile your application. To send it to CloudWatch, see Send profiles to CloudWatch.
Topics
How ingestion works
Your profiler collects stack-trace samples and exports them in OTLP format. You can send the profile data to Amazon CloudWatch Profiles in one of the following ways:
-
Through the CloudWatch agent or an OpenTelemetry Collector – The profiler sends OTLP data to the CloudWatch agent or an OpenTelemetry Collector, which sends it on to Amazon CloudWatch over HTTPS. You can run the Collector anywhere that the profiler can reach, so it doesn't have to run on the same host or network. Running the agent or Collector on the same host is simplest, and is how you usually deploy the CloudWatch agent. If the agent or Collector runs on another host, restrict who can reach it, because profilers that don't sign their requests send the data without authentication. For more information, see Use the CloudWatch agent. For more information about how to configure the agent, see Send OpenTelemetry data using the agent configuration file.
-
Directly to the CloudWatch OTLP endpoint – A client that can sign requests with AWS Signature Version 4 (SigV4), or send an API key, sends profile data over OTLP/HTTP to the endpoint described in Direct OTLP ingestion endpoint.
Authenticate every request to the CloudWatch profiles endpoint. The identity that sends the
request needs the cloudwatch:PutProfileRecords permission. The CloudWatch agent signs requests with SigV4 using its IAM role, such as the Amazon EC2 instance role or the node role. A client that sends directly can sign with SigV4 or use a CloudWatch API key. For more
information, see IAM permissions required.
Some profilers, such as async-profiler, don't sign their requests. These profilers must send profile data through the CloudWatch agent or an OpenTelemetry Collector.
On Kubernetes, the CloudWatch Observability EKS add-on or the Helm chart can turn on the profiler in your Java workloads and send its profiles to CloudWatch. For setup steps, see Profile Java workloads on Kubernetes.
To correlate profiles with your other telemetry in CloudWatch Omni, set the same service name, service namespace, and deployment environment on your profile data as on your metrics, logs, and traces. For the recommended attributes and which ones the CloudWatch agent sets for you, see Recommended resource attributes for correlation.
Prerequisites
Before you send profile data, make sure that you have the following:
-
An AWS account with an IAM role or user that has the permissions described in IAM permissions required.
-
An OTLP-capable profiler, such as async-profiler, the OpenTelemetry eBPF profiler, or the AWS Distro for OpenTelemetry (ADOT) Java agent if you already use it. For more information, see Profile your application.
-
The CloudWatch agent or an OpenTelemetry Collector, unless your client sends profile data directly to the CloudWatch OTLP endpoint. If you use the CloudWatch agent, turn on its OTLP endpoint, which is off by default. For more information, see Use the CloudWatch agent.
Direct OTLP ingestion endpoint
If you send profile data directly to Amazon CloudWatch without the CloudWatch agent or an OpenTelemetry Collector, use the following endpoint details.
- Endpoint
-
https://monitoring.region.amazonaws.com/v1development/profilesReplace
regionwith the AWS Region where you want to store your profile data, for example,us-east-1. - Protocol
-
The endpoint supports OTLP/HTTP only. Send an HTTP
POSTrequest over HTTPS with aContent-Typeofapplication/x-protobuforapplication/json. The endpoint doesn't support gRPC. You can still use gRPC between your profiler and the CloudWatch agent or an OpenTelemetry Collector. - Compression
-
The endpoint accepts gzip-compressed request bodies.
- Authentication
-
AWS Signature Version 4 (SigV4) with the signing service name
monitoring, or a CloudWatch API key sent as a bearer token. For more information, see IAM permissions required. - Profile format version
-
Requests must use OTLP profiles development version
1. For more information, see Supported profile format version.
Supported profile format version
OpenTelemetry profiles is an Alpha signal. For more information, see Profiles/v1development/profiles
URL path. The profile data format might change in incompatible ways during this period. For this
reason, OpenTelemetry labels each export request with a development version: 1,
2, 3, and so on. Clients send the version in the
OTLP-Profiles-Development-Version HTTP request header.
Amazon CloudWatch Profiles supports development version 1:
-
If a request doesn't include the
OTLP-Profiles-Development-Versionheader, CloudWatch treats it as version1and accepts it. -
If the header is
1, CloudWatch accepts the request. -
If the header has any other value, or appears more than once in the request, CloudWatch rejects the request. The response is HTTP
400 Bad Requestwith an OTLPStatusbody. The status code isINVALID_ARGUMENT, and the message isUnsupported OTLP-Profiles-Development-Version header. Supported versions: 1.CloudWatch rejects the request before it reads the profile data. OTLP clients don't retry this error, so you lose the data in the request.
OpenTelemetry Collector versions 0.163.0 and later send the header with the value
1 automatically.
The CloudWatch agent sends profile data to CloudWatch without this header, so CloudWatch accepts it as
version 1. The profiler that sends data to the CloudWatch agent or a Collector must
use a profile format version that the agent or Collector accepts.
IAM permissions required
The identity that sends profile data needs the cloudwatch:PutProfileRecords
permission on the CloudWatch default dataset. If you send profiles through the CloudWatch
agent, the CloudWatchAgentServerPolicy managed policy includes this permission.
For SigV4 authentication from an OpenTelemetry Collector or another client, attach the
following policy:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "PublishProfiles", "Effect": "Allow", "Action": "cloudwatch:PutProfileRecords", "Resource": "arn:aws:cloudwatch:us-east-1:123456789012:dataset/default" } ] }
To send profile data with a CloudWatch API key (bearer token), the IAM user that owns the key
also needs the cloudwatch:CallWithBearerToken permission. The
CloudWatchAPIKeyAccess managed policy includes both
cloudwatch:PutProfileRecords and cloudwatch:CallWithBearerToken. For
more information about API keys, see Setting up bearer token authentication for metrics and profiles.
Permissions for datasets that use a customer managed AWS KMS key
If the default dataset uses a customer managed AWS KMS key, CloudWatch checks
every request to confirm that the caller can use kms:Decrypt on the key. This applies
to the identity that sends profiles, such as the IAM role of the CloudWatch agent, and to every
identity that queries them. The CloudWatchAgentServerPolicy and
CloudWatchAgentAdminPolicy managed policies don't include
kms:Decrypt. For more information about dataset encryption, see Encryption at rest for OpenTelemetry metrics and profiles. To grant this permission, add
the following policy to the identity. In the policy, replace
key-id with the ID of your customer managed key.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "DecryptProfilesDataset", "Effect": "Allow", "Action": "kms:Decrypt", "Resource": "arn:aws:kms:us-east-1:123456789012:key/key-id", "Condition": { "StringEquals": { "kms:ViaService": "cloudwatch.us-east-1.amazonaws.com", "kms:EncryptionContext:aws:cloudwatch:arn": "arn:aws:cloudwatch:us-east-1:123456789012:dataset/default" } } } ] }
The key policy must also allow the identity to use the key. If your key policy keeps the
default statement that lets IAM policies grant access, this policy is enough. Otherwise,
add the identity to the AllowCallerDecrypt statement of the key policy. If the
identity isn't allowed, CloudWatch rejects the request with HTTP status 403.
Verify that profile data is arriving
Profile data appears in CloudWatch about 1–3 minutes after your profiler or
collector exports it for the first time. To confirm that CloudWatch receives your profile data,
find your service and view its flame graph in the CloudWatch console. You need credentials that
have the cloudwatch:GetProfileRecords permission. For more information, see
IAM permissions required.
To verify that profile data is arriving
-
Open the Profiles page of the CloudWatch console
. -
In the navigation bar at the top, choose the Region where you send your profile data.
-
For Service, select the service name that your application reports in
service.name. Each option lists the service and its profile types. -
For Profile type, select the profile type that your profiler sends, for example,
process_cpu. -
At the top of the page, choose a time range that covers the time since your profiler started, for example, 1h.
-
Choose Run.
The results show a time series chart and the flame graph for the service and profile type.
To list the services that sent data with the API, call LabelValues for
the service_name label. For more information, see LabelValues.
If your service doesn't appear, check that the profiler sends data to the correct endpoint and that the signing identity has the permissions in IAM permissions required. To list profile types, retrieve flame graphs, and run other queries, see Query profile data in Amazon CloudWatch and Amazon CloudWatch Profiles query API reference.