Queries the latest monitoring data of a specified metric.
Operation description
Limits
The DescribeMetricLast, DescribeMetricList, DescribeMetricData, and DescribeMetricTop operations share a free quota of 1,000,000 invocations per month in total. After the free quota is exhausted and you have not activated CloudMonitor Basic pay-as-you-go billing method, you cannot use this API operation normally. If you have activated CloudMonitor Basic pay-as-you-go billing method, this API operation remains available after the free quota is exhausted, and the excess usage is automatically billed. For more information about how to activate the pay-as-you-go billing method, see Activate pay-as-you-go billing.
A single API operation is limited to 50 invocations per second. This limit is shared by an Alibaba Cloud account and all Resource Access Management (RAM) users under the account.
If the response contains Throttling.User or Request was denied due to user flow control when you invoke this API operation, the request is throttled. For the method to handle this issue, see How do I handle query API throttling.
Before you begin
The storage duration of cloud service monitoring data depends on the Period (statistical period). A larger Period value results in sparser monitoring data and a longer storage duration. The following list describes the relationship:
If
Periodis less than 60 seconds, the storage duration is 7 days.If
Periodis equal to 60 seconds, the storage duration is 31 days.If
Periodis greater than or equal to 300 seconds, the storage duration is 91 days.
Operation description
This topic provides an example of how to query the latest monitoring data of the CPUUtilization metric for the cloud service acs_ecs_dashboard. The response shows that the maximum value is 100, the minimum value is 93.1, and the average value is 99.52 at 60-second intervals for instance i-abcdefgh12**** under account 123456789876****.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
cms:QueryMetricLast |
get |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| Namespace |
string |
Yes |
The namespace of the cloud service. For information about the namespaces of cloud services, see Cloud service monitoring. |
acs_ecs_dashboard |
| MetricName |
string |
Yes |
The metric name of the cloud service. For information about metric names, see Cloud service monitoring. |
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 time of the query. |
2019-01-31 10:00:00 |
| EndTime |
string |
No |
The end time of the query.
|
2019-01-31 10:10:00 |
| Dimensions |
string |
No |
The monitoring dimensions of the specified resource. Format: a collection of Note
A maximum of 50 instances can be queried in a single request. |
[{"instanceId":"i-2ze2d6j5uhg20x47****"}] |
| NextToken |
string |
No |
The pagination cursor.
|
15761432850009dd70bb64cff1f0fff6c0b08ffff073be5fb1e785e2b020f7fed9b5e137bd810a6d6cff5ae**** |
| Length |
string |
No |
The number of entries per page for the monitoring data. This parameter is used for paging. Default value: 1000, which indicates 1,000 entries of monitoring data per page. Note
The maximum value of Length in a single request is 1440. |
1000 |
| Express |
string |
No |
The expression for real-time computation on existing query results. |
{"groupby":["userId","instanceId"]} |
For more information about common request parameters, see Common parameters.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| NextToken |
string |
The pagination cursor. |
xxxxxx |
| RequestId |
string |
The request ID. |
021472A6-25E3-4094-8D00-BA4B6A5486C3 |
| Success |
boolean |
Indicates whether the operation was successful. Valid values:
|
true |
| Datapoints |
string |
The monitoring data list. |
[{"timestamp":1548777660000,"userId":"123456789876****","instanceId":"i-abcdefgh12****","Minimum":93.1,"Average":99.52,"Maximum":100}] |
| Code |
string |
The status code. Note
A value of 200 indicates success. |
200 |
| Message |
string |
The error message. |
The specified resource is not found. |
| Period |
string |
The time interval. Unit: seconds. |
60 |
Examples
Success response
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. | |
| 500 | InternalError | The request processing has failed due to some unknown error. | |
| 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. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.