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
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.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
cms:QueryMetricTop | get |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
Period | string | No | The statistical period of the monitoring data. Valid values: 15, 60, 900, and 3600. Unit: seconds. Note
| 60 |
Namespace | string | Yes | The namespace of the cloud service. For more information about the namespaces of cloud services, see Appendix 1: Metrics. | acs_ecs_dashboard |
MetricName | string | Yes | The metric that is used to monitor the cloud service. For more information about metric names, see Appendix 1: Metrics. | cpu_idle |
StartTime | string | No | The start of the time range to query monitoring data.
The following formats are supported:
Note
| 2021-05-08 08:00:00 |
EndTime | string | No | The end of the time range to query monitoring data.
The following formats are supported:
Note
We recommend that you use UNIX timestamps to prevent time zone-related issues.
| 2021-05-08 10:00:00 |
Dimensions | string | No | The monitoring dimensions of the specified resource. Set the value to a collection of Note
You can query a maximum of 50 instances in each request.
| [{"instanceId": "i-abcdefgh12****"}] |
Orderby | string | Yes | The field based on which data is sorted. Valid values:
| Average |
OrderDesc | string | No | The order in which data is sorted. Valid values:
| False |
Length | string | No | The number of entries per page. Default value: 10. Note
The maximum value of the Length parameter in a request is 1440.
| 10 |
Express | string | No | 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
Examples
Sample success responses
JSON
format
{
"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 code | Error code | Error message | Description |
---|---|---|---|
400 | ParameterInvalid | Illegal parameters. | - |
403 | AccessForbidden | User not authorized to operate on the specified resource. | - |
404 | ResourceNotFound | The specified resource is not found. | The specified resource is not found. |
500 | InternalError | The request processing has failed due to some unknown error. | - |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|