Amazon CloudWatch Profiles query API reference
Use this reference to look up the request fields, an example request, and the response contents of each query operation. For the endpoint, authentication, and permissions, see Query profile data in Amazon CloudWatch. For examples of common tasks, see Discover profile types, services, and labels, Retrieve a flame graph, Compare two profiles, Retrieve a profile time series, and Find costly spans with a heatmap and trace exemplars.
You can also run the same queries in the CloudWatch console. For more information, see Query profile data in the CloudWatch console.
Common request conventions
All operations follow these conventions.
-
Send an HTTP
POSTrequest with a JSON body and aContent-Typeofapplication/json. -
startandendare in milliseconds since the Unix epoch.stepis in seconds. -
startandendare required onSeries,SelectSeries,SelectMergeStacktraces,SelectHeatmap, and each side ofDiff. A request without them returns HTTP 400 with the messagequery time range must be specified.stepis required onSelectSeriesandSelectHeatmap. -
Label selectors use the form
{and must be wrapped in braces. The operators arekey="value"}=(equals),!=(doesn't equal),=~(matches a regular expression), and!~(doesn't match a regular expression), for example{service_name=~"example-.*"}. Separate multiple matchers with commas. The only short label alias isservice_name. Other labels use full keys, such as@resource.host.name. Quote keys that contain@or., for example,{service_name="example-java-service","@resource.host.name"="host-a.example.internal"}. In a JSON body, escape the inner quotes with backslashes. -
Enumeration values use their full names, such as
EXEMPLAR_TYPE_SPAN. CloudWatch ignores an unknown value without an error and uses the default. -
The response returns 64-bit integers, such as timestamps and totals, as JSON strings.
For more information about limits, see Limits and behavior.
ProfileTypes
Lists every profile type in the account for a time range. This operation doesn't filter by service.
Send requests to the path /querier.v1.QuerierService/ProfileTypes. The following table describes the request fields.
If you omit end, it defaults to the current time. If you omit start, it defaults to 24 hours before end.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
Integer |
No |
Start of the time range, in milliseconds since the Unix epoch. |
|
Integer |
No |
End of the time range, in milliseconds since the Unix epoch. |
The following example shows a request body.
{"start": 1793793600000, "end": 1793797200000}
The response contains a profileTypes list. Each entry has an ID and its parts: name, sampleType, sampleUnit, periodType, and periodUnit. For a full example, see Discover profile types, services, and labels.
This operation doesn't have the 24-hour limit on the time range.
LabelNames
Lists the label names in the profile data for a time range.
Send requests to the path /querier.v1.QuerierService/LabelNames. The following table describes the request fields.
If you omit end, it defaults to the current time. If you omit start, it defaults to 24 hours before end.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
Array of strings |
No |
Label selectors that limit the result to the label names of matching series. Each selector has the form |
|
Integer |
No |
Start of the time range, in milliseconds since the Unix epoch. |
|
Integer |
No |
End of the time range, in milliseconds since the Unix epoch. |
The following example shows a request body.
{"start": 1793793600000, "end": 1793797200000}
The response contains a names list of label names. For a full example, see Discover profile types, services, and labels.
This operation doesn't have the 24-hour limit on the time range. It also accepts an empty request body, {}.
LabelValues
Lists the values of one label for a time range. To list the profile types of one service, use the label name __profile_type__ with a matcher for the service.
Send requests to the path /querier.v1.QuerierService/LabelValues. The following table describes the request fields.
If you omit end, it defaults to the current time. If you omit start, it defaults to 24 hours before end.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
String |
Yes |
The label name, for example, |
|
Array of strings |
No |
Label selectors that limit the profile data to search. Each selector has the form |
|
Integer |
No |
Start of the time range, in milliseconds since the Unix epoch. |
|
Integer |
No |
End of the time range, in milliseconds since the Unix epoch. |
The following example shows a request body.
{"name": "service_name", "start": 1793793600000, "end": 1793797200000}
The response contains a names list of label values. For a full example, see Discover profile types, services, and labels.
This operation doesn't have the 24-hour limit on the time range.
Series
Lists the series, or unique label sets, that match a label selector in a time range.
Send requests to the path /querier.v1.QuerierService/Series. The following table describes the request fields.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
Array of strings |
No |
Label selectors that limit the series. Without |
|
Array of strings |
No |
The labels to return. The response contains one entry for each unique combination of these labels. If you omit |
|
Integer |
Yes |
Start of the time range, in milliseconds since the Unix epoch. The range from |
|
Integer |
Yes |
End of the time range, in milliseconds since the Unix epoch. |
The following example shows a request body.
{ "matchers": ["{service_name=\"example-java-service\"}"], "labelNames": ["service_name", "@resource.host.name"], "start": 1793793600000, "end": 1793797200000 }
The response contains a labelsSet list. Each entry has a labels list of name and value pairs. For a full example, see Discover profile types, services, and labels.
SelectSeries
Returns a time series of the total value of a profile type for each time step, optionally grouped by labels.
Send requests to the path /querier.v1.QuerierService/SelectSeries. The following table describes the request fields.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
String |
No |
The profile type ID, with five parts separated by colons, for example, |
|
String |
No |
A label selector in the form |
|
Integer |
Yes |
Start of the time range, in milliseconds since the Unix epoch. The range from |
|
Integer |
Yes |
End of the time range, in milliseconds since the Unix epoch. |
|
Number |
Yes |
The time between points, in seconds. CloudWatch raises a smaller value to 300 seconds for windows of 1 hour or less, and to 900 seconds for longer windows. |
|
Array of strings |
No |
Label names to group by. The response has one series for each combination of values. Without |
|
Integer |
No |
The maximum number of series to return when you use |
|
String |
No |
How to combine values in each step. Valid values: |
The following example shows a request body.
{ "profileTypeID": "process_cpu:cpu:nanoseconds:cpu:nanoseconds", "labelSelector": "{service_name=\"example-java-service\"}", "step": 600, "start": 1793793600000, "end": 1793797200000 }
The response contains a series list. Each series has labels (when you use groupBy) and points, each with a value and a timestamp string in milliseconds. For a full example, see Retrieve a profile time series.
Keep the following in mind when you use this operation:
-
If you omit
profileTypeID, the result adds together every profile type, even types with different units. IncludeprofileTypeID, or group by__profile_type__. -
CloudWatch ignores an unknown
aggregationvalue without an error and uses the default.
SelectMergeStacktraces
Merges the stack trace samples that match a profile type and label selector, and returns them as flame graph data.
Send requests to the path /querier.v1.QuerierService/SelectMergeStacktraces. The following table describes the request fields.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
String |
Yes |
The profile type ID, with five parts separated by colons, for example, |
|
String |
No |
A label selector in the form |
|
Integer |
Yes |
Start of the time range, in milliseconds since the Unix epoch. The range from |
|
Integer |
Yes |
End of the time range, in milliseconds since the Unix epoch. |
|
Integer |
No |
The approximate maximum number of nodes to return. The value must be 0 or greater. If you omit it, the response contains the full tree. |
|
String |
No |
The response format. Valid values: |
The following example shows a request body.
{ "profileTypeID": "process_cpu:cpu:nanoseconds:cpu:nanoseconds", "labelSelector": "{service_name=\"example-java-service\"}", "start": 1793793600000, "end": 1793797200000 }
The response contains a flamegraph object with names, levels, total, and maxSelf. Each level holds four values for each node: x-offset, total, self, and name index. For a full example, see Retrieve a flame graph.
Keep the following in mind when you use this operation:
-
profileTypeIDis required. A request without it returns HTTP 400. -
maxNodesis approximate. Trimmed nodes roll up into nodes namedother. -
CloudWatch ignores an unknown
formatvalue without an error and uses the default.
Diff
Compares two flame graph selections, a left side and a right side, and returns a combined flame graph.
Send requests to the path /querier.v1.QuerierService/Diff. The following table describes the request fields.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
Object |
Yes |
The first selection. It takes the same fields as a |
|
Object |
Yes |
The second selection, with the same fields as |
The following example shows a request body.
{ "left": {"profileTypeID": "process_cpu:cpu:nanoseconds:cpu:nanoseconds", "labelSelector": "{service_name=\"example-java-service\"}", "start": 1793793600000, "end": 1793795400000}, "right": {"profileTypeID": "process_cpu:cpu:nanoseconds:cpu:nanoseconds", "labelSelector": "{service_name=\"example-java-service\"}", "start": 1793795400000, "end": 1793797200000} }
The response contains a flamegraph object with leftTicks and rightTicks totals. Each level holds seven values for each node: the left offset, total, and self; the right offset, total, and self; and the name index. For a full example, see Compare two profiles.
Keep the following in mind when you use this operation:
-
CloudWatch validates each side separately. Each error message starts with
left:orright:. -
Use the same
profileTypeIDon both sides. The operation doesn't reject sides with different profile types, but the result isn't meaningful.
SelectHeatmap
Returns a heatmap of the profile values of individual trace spans, grouped into time columns and value buckets, with optional trace exemplars.
Send requests to the path /querier.v1.QuerierService/SelectHeatmap. The following table describes the request fields.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
String |
Yes |
The profile type ID, with five parts separated by colons, for example, |
|
String |
No |
A label selector in the form |
|
Integer |
Yes |
Start of the time range, in milliseconds since the Unix epoch. The range from |
|
Integer |
Yes |
End of the time range, in milliseconds since the Unix epoch. |
|
Number |
Yes |
The width of each time column, in seconds. |
|
String |
No |
The heatmap type. Valid value: |
|
String |
No |
Set to |
|
Array of strings |
No |
Label names to group by. The response has one series for each combination of values, with its labels. All series use the same value buckets. |
|
Integer |
No |
The maximum number of series to return when you use |
The following example shows a request body.
{ "profileTypeID": "process_cpu:cpu:nanoseconds:cpu:nanoseconds", "labelSelector": "{service_name=\"example-java-service\"}", "step": 600, "exemplarType": "EXEMPLAR_TYPE_SPAN", "start": 1793793600000, "end": 1793797200000 }
The response contains a series list with slots, one for each time column that has data. Each slot has a timestamp, yMin bucket lower bounds, and counts of spans for each bucket. With EXEMPLAR_TYPE_SPAN, each slot also has exemplars with trace IDs and span IDs. For a full example, see Find costly spans with a heatmap and trace exemplars.
Keep the following in mind when you use this operation:
-
stepandprofileTypeIDare required. A request withoutprofileTypeIDreturns HTTP 400. -
Each slot has 20 value buckets.
-
The heatmap includes only profile data that is linked to trace spans. If no such data exists in the time range, the response is an empty object,
{}. -
CloudWatch ignores unknown or shortened enumeration values, such as
SPAN, without an error and uses the default. With"exemplarType": "SPAN", the response contains no exemplars.