All Products
Search
Document Center

CloudMonitor:DescribeMetricTop

最終更新日:Jul 26, 2024

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

Operation description

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.

Description

This topic provides an example to show 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 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.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
cms:QueryMetricTopget
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
PeriodstringNo

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.

60
NamespacestringYes

The namespace of the cloud service.

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

acs_ecs_dashboard
MetricNamestringYes

The metric that is used to monitor the cloud service.

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

cpu_idle
StartTimestringNo

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.````

    • 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.

2021-05-08 08:00:00
EndTimestringNo

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.````

    • 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.
2021-05-08 10:00:00
DimensionsstringNo

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 each request.
[{"instanceId": "i-abcdefgh12****"}]
OrderbystringYes

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

  • Average
  • Minimum
  • Maximum
Average
OrderDescstringNo

The order in which data is sorted. Valid values:

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

The number of entries per page.

Default value: 10.

Note The maximum value of the Length parameter in a request is 1440.
10
ExpressstringNo

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 used in databases.
{"groupby":["userId","instanceId"]}

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

Response parameters

ParameterTypeDescriptionExample
object
Codestring

The HTTP status code.

Note The status code 200 indicates that the request was successful.
200
Messagestring

The error message.

The specified resource is not found.
RequestIdstring

The request ID.

3121AE7D-4AFF-4C25-8F1D-C8226EBB1F42
Datapointsstring

The monitoring data.

[{\"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}]
Periodstring

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

60

Examples

Sample success responses

JSONformat

{
  "Code": "200",
  "Message": "The specified resource is not found.",
  "RequestId": "3121AE7D-4AFF-4C25-8F1D-C8226EBB1F42",
  "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}]",
  "Period": "60"
}

Error codes

HTTP status codeError codeError messageDescription
400ParameterInvalidIllegal parameters.-
403AccessForbiddenUser not authorized to operate on the specified resource.-
404ResourceNotFoundThe specified resource is not found.The specified resource is not found.
500InternalErrorThe request processing has failed due to some unknown error.-

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
No change history