View a markdown version of this page

Amazon CloudWatch Profiles query API reference - Amazon CloudWatch

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 POST request with a JSON body and a Content-Type of application/json.

  • start and end are in milliseconds since the Unix epoch. step is in seconds.

  • start and end are required on Series, SelectSeries, SelectMergeStacktraces, SelectHeatmap, and each side of Diff. A request without them returns HTTP 400 with the message query time range must be specified. step is required on SelectSeries and SelectHeatmap.

  • Label selectors use the form {key="value"} and must be wrapped in braces. The operators are = (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 is service_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.

ProfileTypes request fields

Field

Type

Required

Description

start

Integer

No

Start of the time range, in milliseconds since the Unix epoch.

end

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.

LabelNames request fields

Field

Type

Required

Description

matchers

Array of strings

No

Label selectors that limit the result to the label names of matching series. Each selector has the form {key="value"}. For the syntax, see Common request conventions.

start

Integer

No

Start of the time range, in milliseconds since the Unix epoch.

end

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.

LabelValues request fields

Field

Type

Required

Description

name

String

Yes

The label name, for example, service_name or __profile_type__. A label name that doesn't exist returns an empty result. A request without name returns HTTP 400 with the message label name is required.

matchers

Array of strings

No

Label selectors that limit the profile data to search. Each selector has the form {key="value"}. For the syntax, see Common request conventions.

start

Integer

No

Start of the time range, in milliseconds since the Unix epoch.

end

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.

Series request fields

Field

Type

Required

Description

matchers

Array of strings

No

Label selectors that limit the series. Without matchers, the operation searches all profile data. Each selector has the form {key="value"}. For the syntax, see Common request conventions.

labelNames

Array of strings

No

The labels to return. The response contains one entry for each unique combination of these labels. If you omit labelNames, the response contains one entry for each series, with all of the series' labels.

start

Integer

Yes

Start of the time range, in milliseconds since the Unix epoch. The range from start to end can't be longer than 24 hours.

end

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.

SelectSeries request fields

Field

Type

Required

Description

profileTypeID

String

No

The profile type ID, with five parts separated by colons, for example, process_cpu:cpu:nanoseconds:cpu:nanoseconds. If you omit it, the query adds together the values of all profile types.

labelSelector

String

No

A label selector in the form {key="value"}. For the syntax, see Common request conventions. If you omit it, the query includes all series of the profile type. {} also matches all profile data.

start

Integer

Yes

Start of the time range, in milliseconds since the Unix epoch. The range from start to end can't be longer than 24 hours.

end

Integer

Yes

End of the time range, in milliseconds since the Unix epoch.

step

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.

groupBy

Array of strings

No

Label names to group by. The response has one series for each combination of values. Without groupBy, the response has one series.

limit

Integer

No

The maximum number of series to return when you use groupBy.

aggregation

String

No

How to combine values in each step. Valid values: TIME_SERIES_AGGREGATION_TYPE_SUM (the default), which adds the values together, and TIME_SERIES_AGGREGATION_TYPE_AVERAGE, which averages them.

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. Include profileTypeID, or group by __profile_type__.

  • CloudWatch ignores an unknown aggregation value 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.

SelectMergeStacktraces request fields

Field

Type

Required

Description

profileTypeID

String

Yes

The profile type ID, with five parts separated by colons, for example, process_cpu:cpu:nanoseconds:cpu:nanoseconds.

labelSelector

String

No

A label selector in the form {key="value"}. For the syntax, see Common request conventions. If you omit it, the query includes all series of the profile type.

start

Integer

Yes

Start of the time range, in milliseconds since the Unix epoch. The range from start to end can't be longer than 24 hours.

end

Integer

Yes

End of the time range, in milliseconds since the Unix epoch.

maxNodes

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.

format

String

No

The response format. Valid values: PROFILE_FORMAT_FLAMEGRAPH (the default), which returns a flamegraph object, and PROFILE_FORMAT_TREE, which returns base64-encoded tree data in a tree field.

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:

  • profileTypeID is required. A request without it returns HTTP 400.

  • maxNodes is approximate. Trimmed nodes roll up into nodes named other.

  • CloudWatch ignores an unknown format value 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.

Diff request fields

Field

Type

Required

Description

left

Object

Yes

The first selection. It takes the same fields as a SelectMergeStacktraces request, including profileTypeID, labelSelector, start, end, and maxNodes. Its time range can't be longer than 24 hours.

right

Object

Yes

The second selection, with the same fields as left. Its time range can't be longer than 24 hours.

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: or right:.

  • Use the same profileTypeID on 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.

SelectHeatmap request fields

Field

Type

Required

Description

profileTypeID

String

Yes

The profile type ID, with five parts separated by colons, for example, process_cpu:cpu:nanoseconds:cpu:nanoseconds.

labelSelector

String

No

A label selector in the form {key="value"}. For the syntax, see Common request conventions. If you omit it, the query includes all series of the profile type.

start

Integer

Yes

Start of the time range, in milliseconds since the Unix epoch. The range from start to end can't be longer than 24 hours.

end

Integer

Yes

End of the time range, in milliseconds since the Unix epoch.

step

Number

Yes

The width of each time column, in seconds.

queryType

String

No

The heatmap type. Valid value: HEATMAP_QUERY_TYPE_SPAN, which is the default. HEATMAP_QUERY_TYPE_INDIVIDUAL isn't supported.

exemplarType

String

No

Set to EXEMPLAR_TYPE_SPAN to add trace exemplars to each time column. By default, the response contains no exemplars.

groupBy

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.

limit

Integer

No

The maximum number of series to return when you use groupBy. Must be 0 or greater. 0 returns all series.

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:

  • step and profileTypeID are required. A request without profileTypeID returns 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.