Queries the latest monitoring data of a metric for a cloud service. The data can be sorted by a specified order.

Limits

Each API operation can be called up to 10 times per second. An Alibaba Cloud account and the RAM users within the account share the quota.

Precautions

The storage duration of the monitoring data of each cloud service is related to the Period parameter (statistical period). A larger value of the Period parameter indicates that the monitoring data is distributed in a larger time range and the storage duration of the monitoring data is longer. The following list describes the specific relationships:

  • If the value of the Period parameter is less than 60 seconds, the storage duration is seven days.
  • If the value of the Period parameter is 60 seconds, the storage duration is 31 days.
  • If the value of the Period parameter is 300 seconds, the storage duration is 91 days.

Usage notes

This topic provides an example on how to query the monitoring data of the cpu_idle metric in the last 60 seconds for Elastic Compute Service (ECS). The namespace of ECS is acs_ecs_dashboard. The monitoring data is sorted in descending order based on the Average field.

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

ParameterTypeRequiredExampleDescription
ActionStringYesDescribeMetricTop

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

PeriodStringNo60

The statistical period of the monitoring data.

Valid values: 15, 60, 900, and 3600.

Unit: seconds.

Note
  • If this parameter is not specified, monitoring data is queried based on the period in which metric values are reported.
  • Statistical periods vary based on the metrics that are specified by MetricName. For more information, see Appendix 1: Metrics.
NamespaceStringYesacs_ecs_dashboard

The namespace of the cloud service.

For more information about the namespaces of cloud services, see Appendix 1: Metrics.

MetricNameStringYescpu_idle

The metric that is used to monitor the cloud service.

For more information about metric names, see Appendix 1: Metrics.

StartTimeStringNo2021-05-08 08:00:00

The start of the time range to query monitoring data.

  • If the StartTime and EndTime parameters are not specified, the monitoring data of the last statistical period is queried.
  • If the StartTime and EndTime parameters are specified, the monitoring data of the last statistical period in the specified time range is queried. The following examples demonstrate how to determine the period in which monitoring data is queried:
    • 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 two 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 3,600 seconds in the time range is queried.

The following formats are supported:

  • 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. Otherwise, this parameter is invalid.
  • We recommend that you use UNIX timestamps to prevent time zone-related issues.
EndTimeStringNo2021-05-08 10:00:00

The end of the time range to query monitoring data.

  • If the StartTime and EndTime parameters are not specified, the monitoring data of the last statistical period is queried.
  • If the StartTime and EndTime parameters are specified, the monitoring data of the last statistical period in the specified time range is queried. The following examples demonstrate how to determine the period in which monitoring data is queried:
    • 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 two 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 3,600 seconds in the time range is queried.

The following formats are supported:

  • 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.
DimensionsStringNo[{"instanceId": "i-2ze2d6j5uhg20x47****"}]

The monitoring dimensions of the specified resource.

Set the value to a collection of key:value pairs. Example: {"userId":"120886317861****"} or {"instanceId":"i-2ze2d6j5uhg20x47****"}.

Note You can query a maximum of 50 instances in a single request.
OrderbyStringYesAverage

The field based on which data is sorted. Valid values:

  • Average: the average value
  • Minimum: the minimum value
  • Maximum: the maximum value
OrderDescStringNoFalse

The order in which data is sorted. Valid values:

  • True: sorts data in ascending order.
  • False (default): sorts data in descending order.
LengthStringNo10

The number of entries per page.

Default value: 10.

Note The maximum value of the Length parameter in a request is 1440.
ExpressStringNo{"groupby":["userId","instanceId"]}

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

Note Only the groupby expression is supported. This expression is similar to the GROUP BY statement that is used in databases.

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

Response parameters

ParameterTypeExampleDescription
CodeString200

The status code.

Note The status code 200 indicates that the request was successful.
MessageStringThe specified resource is not found.

The error message.

RequestIdString3121AE7D-4AFF-4C25-8F1D-C8226EBB1F42

The request ID.

DatapointsString[{\"order\":1,\"timestamp\":1620287520000,\"userId\":\"120886317861****\",\"instanceId\":\"i-j6ccf7d5fn335qpo****\",\"Average\":99.92,\"Minimum\":99.5,\"Maximum\":100.0,\"_count\":1.0},{\"order\":2,\"timestamp\":1620287520000,\"userId\":\"120886317861****\",\"instanceId\":\"i-0xii2bvf42iqvxbp****\",\"Average\":99.91,\"Minimum\":99.0,\"Maximum\":100.0,\"_count\":1.0}]

The monitoring data.

PeriodString60

The statistical period of the monitoring data. Unit: seconds. Valid values: 15, 60, 900, and 3600.

Examples

Sample requests

http(s)://[Endpoint]/?Action=DescribeMetricTop
&MetricName=cpu_idle
&Namespace=acs_ecs_dashboard
&Period=60
&Orderby=Average
&OrderDesc=False
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<DescribeMetricTopResponse>
    <RequestId>18DC44ED-B058-49B0-9D49-1D6608328E4D</RequestId>
    <Period>60</Period>
    <Datapoints>[{\"order\":1,\"timestamp\":1620287520000,\"userId\":\"120886317861****\",\"instanceId\":\"i-j6ccf7d5fn335qpo****\",\"Average\":99.92,\"Minimum\":99.5,\"Maximum\":100.0,\"_count\":1.0},{\"order\":2,\"timestamp\":1620287520000,\"userId\":\"120886317861****\",\"instanceId\":\"i-0xii2bvf42iqvxbp****\",\"Average\":99.91,\"Minimum\":99.0,\"Maximum\":100.0,\"_count\":1.0}]</Datapoints>
    <Code>200</Code>
</DescribeMetricTopResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "18DC44ED-B058-49B0-9D49-1D6608328E4D",
  "Period" : "60",
  "Datapoints" : "[{\"order\":1,\"timestamp\":1620287520000,\"userId\":\"120886317861****\",\"instanceId\":\"i-j6ccf7d5fn335qpo****\",\"Average\":99.92,\"Minimum\":99.5,\"Maximum\":100.0,\"_count\":1.0},{\"order\":2,\"timestamp\":1620287520000,\"userId\":\"120886317861****\",\"instanceId\":\"i-0xii2bvf42iqvxbp****\",\"Average\":99.91,\"Minimum\":99.0,\"Maximum\":100.0,\"_count\":1.0}]",
  "Code" : "200"
}

Error codes

HTTP status codeError codeError messageDescription
404ResourceNotFoundThe specified resource is not found.The specified resource is not found.

For a list of error codes, see Service error codes.