Queries the monitoring data of a metric for a cloud service.

This topic describes how to query the monitoring data of the last 60 seconds for the cpu_idle metric of the acs_ecs_dashboard cloud service.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes DescribeMetricLast

The operation that you want to perform. Set the value to DescribeMetricLast.

MetricName String Yes cpu_idle

The name of the metric. For more information, see Metrics.

Namespace String Yes acs_ecs_dashboard

The namespace of the cloud service. For more information, see Metrics.

Period String No 60

The interval at which monitoring data is collected. Unit: seconds. Valid values: 15, 60, 900, and 3600.

Note If this parameter is not specified, monitoring data is queried at the interval at which the metric data is reported.
StartTime String No 2021-05-08 08:00:00

The start of the time range to query monitoring data.

  • If the StartTime and EndTime parameters are not set, the monitoring data of the last interval is queried.
  • If the StartTime and EndTime parameters are set, the monitoring data of the last interval in the time range is queried. Example:
    • If you set the Period parameter to 15, the specified time range must be less than or equal to 20 minutes. For example, if you set the StartTime parameter to 2021-05-08 08:10:00 and the EndTime parameter to 2021-05-08 08:30:00, the monitoring data of the last 15 seconds in the time range is queried.
    • If you set the Period parameter to 60 or 900, the specified time range must be less than or equal to 2 hours. For example, if you set the Period parameter to 60, the StartTime parameter to 2021-05-08 08:00:00, and the EndTime parameter to 2021-05-08 10:00:00, the monitoring data of the last 60 seconds in the time range is queried.
    • If you set the Period parameter to 3600, the specified time range must be less than or equal to 2 days. For example, if you set the StartTime parameter to 2021-05-08 08:00:00 and the EndTime parameter to 2021-05-10 08:00:00, the monitoring data of the last 3600 seconds in the time range is queried.

Supported formats of the start time:

  • UNIX timestamp: the number of milliseconds that have elapsed since 00:00:00 Thursday, January 1, 1970.
  • Time format: YYYY-MM-DDThh:mm:ssZ.
Note
  • You must set the StartTime parameter to a point in time that is later than 00:00:00 Thursday, January 1, 1970.
  • We recommend that you use UNIX timestamps to prevent time zone-related issues.
EndTime String No 2021-05-08 10:00:00

The end of the time range to query monitoring data.

  • If the StartTime and EndTime parameters are not set, the monitoring data of the last interval is queried.
  • If the StartTime and EndTime are set, the monitoring data of the last interval in the time range is queried. Example:
    • If you set the Period parameter to 15, the specified time range must be less than or equal to 20 minutes. For example, if you set the StartTime parameter to 2021-05-08 08:10:00 and the EndTime parameter to 2021-05-08 08:30:00, the monitoring data of the last 15 seconds in the time range is queried.
    • If you set the Period parameter to 60 or 900, the specified time range must be less than or equal to 2 hours. For example, if you set the Period parameter to 60, the StartTime parameter to 2021-05-08 08:00:00, and the EndTime parameter to 2021-05-08 10:00:00, the monitoring data of the last 60 seconds in the time range is queried.
    • If you set the Period parameter to 3600, the specified time range must be less than or equal to 2 days. For example, if you set the StartTime parameter to 2021-05-08 08:00:00 and the EndTime parameter to 2021-05-10 08:00:00, the monitoring data of the last 3600 seconds in the time range in queried.

Supported formats of the end time:

  • UNIX timestamp: the number of milliseconds that have elapsed since 00:00:00 Thursday, January 1, 1970.
  • Time format: YYYY-MM-DDThh:mm:ssZ.
Note We recommend that you use UNIX timestamps to prevent time zone-related issues.
Dimensions String No [{"instanceId":"i-abcdefgh12****"}]

The dimensions. This parameter is used to specify the resources whose monitoring data is queried.

This parameter includes a set of key-value pairs. Example: instanceId:i-2ze2d6j5uhg20x47****.

Note For more information, see Metrics.
NextToken String No EB71D183-45BF-414D-AC36-42FCE094E561

The paging token.

  • If the number of results exceeds the maximum number of entries allowed on a single page, a paging token is returned.
  • This token can be used as an input parameter to obtain the next page of results. If all results are obtained, no token is returned.
Length String No 1000

The number of entries to return on each page. Default value: 1000.

Express String No {"groupby":["userId","instanceId"]}

The expression that is used to calculate the query results in real time.

For more information about common request parameters, see Common parameters.

Response parameters

Parameter Type Example Description
RequestId String EB71D183-45BF-414D-AC36-42FCE094E561

The ID of the request.

Code String 200

The HTTP status code.

Note The HTTP status code 200 indicates that the request succeeds.
Success Boolean true

Indicates whether the call succeeds. Valid values:

  • true: The call succeeds.
  • false: The call fails.
Period String 60

The interval at which monitoring data is queried. Unit: seconds.

NextToken String 1620367920000457f80f8dbce544141470dd218c582c73813b72331323038383633313738363132393533242c692d327a65343233706d683933356f78743067726a32****

The paging token.

Datapoints String [{\"timestamp\":1620367920000,\"userId\":\"120886317861****\",\"instanceId\":\"i-0xii2bvf42iqvxbp****\",\"Average\":99.91,\"Minimum\":99.0,\"Maximum\":100.0},{\"timestamp\":1620367920000,\"userId\":\"120886317861****\",\"instanceId\":\"i-2ze1qff61suafi71****\",\"Average\":98.89,\"Minimum\":97.03,\"Maximum\":100.0},{\"timestamp\":1620367920000,\"userId\":\"120886317861****\",\"instanceId\":\"i-2ze423pmh935oxt0****\",\"Average\":89.3,\"Minimum\":74.11,\"Maximum\":97.98}]

The list of monitoring data.

Message String The specified resource is not found.

The error message.

Examples

Sample requests

http(s)://[Endpoint]/?Action=DescribeMetricLast
&MetricName=CPUUtilization
&Namespace=acs_ecs_dashboard
&Period=60
&<Common request parameters>

Sample success responses

XML format

<QueryMetricListResponse>
      <RequestId>EB71D183-45BF-414D-AC36-42FCE094E561</RequestId>
      <NextToken>1620367920000457f80f8dbce544141470dd218c582c73813b72331323038383633313738363132393533242c692d327a65343233706d683933356f78743067726a32****</NextToken>
      <Period>60</Period>
      <Datapoints>[{\"timestamp\":1620367920000,\"userId\":\"120886317861****\",\"instanceId\":\"i-0xii2bvf42iqvxbp****\",\"Average\":99.91,\"Minimum\":99.0,\"Maximum\":100.0},{\"timestamp\":1620367920000,\"userId\":\"120886317861****\",\"instanceId\":\"i-2ze1qff61suafi71****\",\"Average\":98.89,\"Minimum\":97.03,\"Maximum\":100.0},{\"timestamp\":1620367920000,\"userId\":\"120886317861****\",\"instanceId\":\"i-2ze423pmh935oxt0****\",\"Average\":89.3,\"Minimum\":74.11,\"Maximum\":97.98}]</Datapoints>
      <Code>200</Code>
      <Success>true</Success>
</QueryMetricListResponse>

JSON format

{
  "RequestId": "EB71D183-45BF-414D-AC36-42FCE094E561",
  "NextToken": "1620367920000457f80f8dbce544141470dd218c582c73813b72331323038383633313738363132393533242c692d327a65343233706d683933356f78743067726a32****",
  "Period": "60",
  "Datapoints": "[{\"timestamp\":1620367920000,\"userId\":\"120886317861****\",\"instanceId\":\"i-0xii2bvf42iqvxbp****\",\"Average\":99.91,\"Minimum\":99.0,\"Maximum\":100.0},{\"timestamp\":1620367920000,\"userId\":\"120886317861****\",\"instanceId\":\"i-2ze1qff61suafi71****\",\"Average\":98.89,\"Minimum\":97.03,\"Maximum\":100.0},{\"timestamp\":1620367920000,\"userId\":\"120886317861****\",\"instanceId\":\"i-2ze423pmh935oxt0****\",\"Average\":89.3,\"Minimum\":74.11,\"Maximum\":97.98}]",
  "Code": "200",
  "Success": true
}

Error codes

HttpCode Error code Error message Description
404 ResourceNotFound The specified resource is not found. The error message returned because the specified resource is not found.

For a list of error codes, visit the API Error Center.