View a markdown version of this page

Retrieve a profile time series - Amazon CloudWatch

Retrieve a profile time series

The SelectSeries operation returns the total value of a profile type for each time step in a range. You can group the result by labels, for example, to get one series for each host. Use a time series to find when resource usage changed, and then retrieve a flame graph for that period. For more information about profile types and labels, see Profile type IDs and labels.

You can view a profile time series in the CloudWatch console or retrieve it with the query API. This topic describes the console first, and then the API.

Prerequisites

Before you begin, make sure that you have the following:

View a profile time series in the CloudWatch console

In the CloudWatch console, the results show a time series chart of the profile value over the selected time range, together with the flame graph.

To view a profile time series in the CloudWatch console
  1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.

  2. In the navigation pane, choose Profiles.

  3. In the navigation bar at the top, select the Region where you send your profile data.

  4. For Service, select the service name that your application reports in service.name, for example, example-java-service.

  5. For Profile type, select the profile type that your profiler sends, for example, process_cpu.

  6. At the top of the page, choose the time range that you want to analyze, for example, 1h.

  7. Choose Run.

The chart title shows the unit of the profile type, for example, CPU cores. The chart legend shows the name of the profile type.

To get one series for each value of a label, such as one series for each host, use the groupBy field of the SelectSeries API operation. For an example, see Example: CPU time for each host of a service.

Time series examples

To retrieve a profile time series with the API, send a SelectSeries request. The following examples show common requests and a response.

A SelectSeries request requires step, in seconds. The time range can't be longer than 24 hours. CloudWatch raises a smaller step to the minimum resolution for the time range: 300 seconds for windows of 1 hour or less, and 900 seconds for longer windows. For all request fields, see SelectSeries in the query API reference.

Note

Always include profileTypeID. If you omit it, CloudWatch adds together the values of every profile type that matches the label selector, even types with different units such as nanoseconds and counts. To see each type separately, group by __profile_type__.

Example: CPU time for each host of a service

This request returns the CPU time of example-java-service in 10-minute steps, with one series for each host.

curl --request POST \ --aws-sigv4 "aws:amz:us-east-1:monitoring" \ --user "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" \ --header "x-amz-security-token: $AWS_SESSION_TOKEN" \ --header "Content-Type: application/json" \ --data '{ "profileTypeID": "process_cpu:cpu:nanoseconds:cpu:nanoseconds", "labelSelector": "{service_name=\"example-java-service\"}", "step": 600, "groupBy": ["@resource.host.name"], "start": 1793793600000, "end": 1793797200000 }' \ https://monitoring.us-east-1.amazonaws.com/querier.v1.QuerierService/SelectSeries

Example response (trimmed):

{ "series": [ { "labels": [{"name": "@resource.host.name", "value": "host-a.example.internal"}], "points": [ {"value": 1461305600.0, "timestamp": "1793796000000"}, {"value": 7860000000.0, "timestamp": "1793796600000"} ] }, { "labels": [{"name": "@resource.host.name", "value": "host-b.example.internal"}], "points": [...] } ] }

Each point has a value in the unit of the profile type and a timestamp in milliseconds, returned as a string. Without groupBy, the response contains one series with no labels.

Example: average CPU time, limited to one series

This request body averages the values in each step instead of adding them, and limit restricts the response to one series.

{ "profileTypeID": "process_cpu:cpu:nanoseconds:cpu:nanoseconds", "labelSelector": "{service_name=\"example-java-service\"}", "step": 600, "groupBy": ["@resource.host.name"], "limit": 1, "aggregation": "TIME_SERIES_AGGREGATION_TYPE_AVERAGE", "start": 1793793600000, "end": 1793797200000 }
Example: one series for each profile type

This request body omits profileTypeID and groups by __profile_type__, so the response contains a separate series for each profile type in the account.

{ "labelSelector": "{}", "step": 900, "groupBy": ["__profile_type__"], "start": 1793793600000, "end": 1793797200000 }