Queries the latest monitoring data of a metric.
Operation description
Limits
Each API operation can be called up to 50 times per second. An Alibaba Cloud account and the RAM users within the account share the quota.
Throttling.User
or Request was denied due to user flow control
is returned when you call an API operation, the API operation is throttled. For more information about how to handle the issue, see How do I handle the throttling of a query API?
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 on how to query the latest monitoring data of the CPUUtilization
metric for Elastic Compute Service (ECS). The namespace of ECS is acs_ecs_dashboard
. The returned result indicates that the monitoring data for the instance i-abcdefgh12****
of the account 123456789876****
is queried at an interval of 60 seconds. The maximum, minimum, and average values of the metric are 100, 93.1, and 99.52.
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:QueryMetricLast | get |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
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. | CPUUtilization |
Period | string | No | The statistical period of the monitoring data. Valid values: 15, 60, 900, and 3600. Unit: seconds. Note
| 60 |
StartTime | string | No | The start of the time range to query monitoring data. | 2019-01-31 10:00:00 |
EndTime | string | No | The end of the time range to query monitoring data.
| 2019-01-31 10:10: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****"}] |
NextToken | string | No | The pagination token.
| 15761432850009dd70bb64cff1f0fff6c0b08ffff073be5fb1e785e2b020f7fed9b5e137bd810a6d6cff5ae**** |
Length | string | No | The number of entries per page. Default value: 1000. This value indicates that a maximum of 1,000 entries of monitoring data can be returned on each page. Note
The maximum value of the Length parameter for each request is 1440.
| 1000 |
Express | string | No | The expression that is used to calculate the query results in real time. | {"groupby":["userId","instanceId"]} |
For more information about common request parameters, see Common parameters.
Response parameters
Examples
Sample success responses
JSON
format
{
"NextToken": "xxxxxx",
"RequestId": "021472A6-25E3-4094-8D00-BA4B6A5486C3",
"Success": true,
"Datapoints": "[{\"timestamp\":1548777660000,\"userId\":\"123456789876****\",\"instanceId\":\"i-abcdefgh12****\",\"Minimum\":93.1,\"Average\":99.52,\"Maximum\":100}]",
"Code": "200",
"Message": "The specified resource is not found.",
"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 |
---|