Profile your application
To send data to Amazon CloudWatch Profiles, use a profiler that produces data in OpenTelemetry Protocol (OTLP) format. CloudWatch doesn't own most of the tools described here, so this page summarizes each option and links to its documentation.
If you send through the CloudWatch agent, turn on its OTLP endpoint first. For more information, see Use the CloudWatch agent.
On Kubernetes, the CloudWatch Observability EKS add-on and the
amazon-cloudwatch-observability Helm chart turn on the profiler in
your Java workloads and send the profiles to CloudWatch for you. For more information,
see Profile Java workloads on Kubernetes.
To send the data to CloudWatch, see Send profiles to CloudWatch.
Use one of the following options:
-
async-profiler – A low-overhead sampling profiler for Java. Version 4.6 and later send OTLP over HTTP when the output file name is an
http://orhttps://URL. Sending needs libcurl on the host or in the application's container. With OTLP output, async-profiler records one event at a time. We recommendevent=itimer. It stores the profile typeprocess_itimer:itimer:count:itimer:nson any host. For configuration, see the async-profilerrepository on the GitHub website. Start your application with
OTEL_SERVICE_NAMEset, or with theotel.service.namesystem property, because async-profiler reads the service name from the profiled JVM. Then run the following command against the running process.asprof -e itimer --loop 60s -f http://localhost:4318/v1development/profilespid-
– The process ID of your running Java application.pid
-
-
OpenTelemetry eBPF profiler – Samples the stacks of every process on a Linux host from the kernel, without changes to your applications. By default, it samples on-CPU time. You can run it yourself for applications in languages other than Java. It runs as the
profilingreceiver in theotelcol-ebpf-profilerOpenTelemetry Collector distribution. It doesn't sign requests, so export its data to the CloudWatch agent or an OpenTelemetry Collector.The profiler runs with elevated privileges and can read the memory and environment of every process on the host. Run it only on hosts that you control. CloudWatch rejects a profile with more than 16,000 samples, so don't raise the
reporter_intervalof the receiver. If a process has noservice.name, the CloudWatch agent stores its profiles underunknown_service. The opentelemetry-ebpf-profilerrepository on the GitHub website describes setup, required privileges, supported runtimes, and the supported Collector distribution to deploy. For example, save the following configuration as
config.yaml. It sends the profiles to the CloudWatch agent on the same host.receivers: profiling: {} exporters: otlp_http: profiles_endpoint: http://localhost:4318/v1development/profiles service: pipelines: profiles: receivers: [profiling] exporters: [otlp_http]Start the Collector with the profiles feature gate:
sudo ./otelcol-ebpf-profiler --config config.yaml --feature-gates=+service.profilesSupport -
ADOT Java agent – Version 2.32.0 and later of the AWS Distro for OpenTelemetry (ADOT) Java agent embed async-profiler for HotSpot Java virtual machines (JVMs) on Linux, on x86_64 and arm64. The profiler is off by default. To download the agent, see the aws-otel-java-instrumentation releases
on the GitHub website. To turn it on, set the following environment variables when you start your application. Replace
with your service name andmy-servicewith the path to your application JAR file.my-app.jarOTEL_AWS_PROFILER_ENABLED=true \ OTEL_SERVICE_NAME=my-service\ java -javaagent:/opt/aws-opentelemetry-agent/aws-opentelemetry-agent.jar -jarmy-app.jarYou can also set the following variables:
-
OTEL_AWS_PROFILER_MODE– Sets the profiling mode.wall(default) samples threads on and off the CPU.cpusamples only threads running on the CPU. -
OTEL_AWS_PROFILER_MEMORY_ENABLED– Turns on memory allocation profiling when set totrue. The default isfalse. The CloudWatch Observability EKS add-on and the Helm chart set it totrue. -
OTEL_AWS_PROFILER_WINDOW_SECONDS– Sets the length of each profile, in seconds. The default is60. -
OTEL_AWS_PROFILER_ENDPOINT– Sets where the agent sends profiles, used as given. If unset, the agent usesOTEL_EXPORTER_OTLP_ENDPOINT, with/v1development/profilesappended for OTLP/HTTP. If neither is set, it useshttp://localhost:4318/v1development/profilesfor OTLP/HTTP, orhttp://localhost:4317whenOTEL_EXPORTER_OTLP_PROTOCOL=grpc. The default OTLP/HTTP endpoint is the default endpoint of the CloudWatch agent.
-
-
Build your own – Any client can send profiles if it produces OTLP profile data in development version
1. It must also either sign its requests or send them through the CloudWatch agent or a Collector. For more information about authentication, see Send directly to the endpoint. For more information about the data format, see the OpenTelemetry profiles protocolon the GitHub website. For more information about the version that CloudWatch accepts, see Supported profile format version.