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

This topic describes how to query the monitoring data of the acs_ecs_dashboard cloud service. In this example, the monitoring data in the last 60 seconds of the cpu_idle metric is queried, and the data is sorted in the 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

Parameter Type Required Example Description
Action String Yes DescribeMetricTop

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

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.

Orderby String Yes Average

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

  • Average: the average value
  • Minimum: the minimum value
  • Maximum: the maximum value
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 specified, the monitoring data of the last interval is queried.
  • If the StartTime and EndTime parameters are specified, the monitoring data of the last interval in the time range is queried. Examples:
    • 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 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. Otherwise, this parameter is invalid.
  • 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 specified, the monitoring data of the last interval is queried.
  • If the StartTime and EndTime parameters are specified, the monitoring data of the last interval in the time range is queried. Examples:
    • 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 This parameter must be a JSON string. The dimensions must be passed to the JSON string in a specified order.
OrderDesc String No False

The order in which data is sorted. Valid values:

  • True: sorts data in the ascending order.
  • False: sorts data in the descending order. Default value: false.
Length String No 10

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

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

The expression that is used to perform real-time computation on the query results.

Only the groupby expression is supported. This expression is similar to the GROUP BY statement that applies to databases.

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

Response parameters

Parameter Type Example Description
RequestId String 3121AE7D-4AFF-4C25-8F1D-C8226EBB1F42

The ID of the request.

Code String 200

The HTTP status code.

Note The HTTP status code 200 indicates that the call succeeds.
Datapoints String [{\"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 list of monitoring data.

Period String 60

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

Message String The specified resource is not found.

The error message.

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

<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

{
    "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

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.