Queries the latest monitoring data of a specified metric.
Operation description
Before you begin
Invocations of DescribeMetricLast, DescribeMetricList, DescribeMetricData, and DescribeMetricTop share a combined free quota of 1,000,000 calls per month. After the free quota is exhausted, if you have not activated CloudMonitor Basic pay-as-you-go billing method, you cannot use this API normally. If you have activated CloudMonitor Basic pay-as-you-go billing method, the API continues to work after the free quota is exhausted, and usage beyond the free quota is automatically billed. For the method to activate pay-as-you-go billing, see Activate pay-as-you-go billing.
The rate limit for a single API operation is 50 calls per second. This limit is shared by an Alibaba Cloud account and all Resource Access Management (RAM) users under the account.
When you invoke an API operation, if the response contains Throttling.User or Request was denied due to user flow control, the API is being throttled. For the handling method, see How do I handle query API throttling.
Notes
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 relationships are as follows:
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 for instance i-abcdefgh12**** under account 123456789876****, the maximum value is 100, the minimum value is 93.1, and the average value is 99.52 at a 60-second interval.
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 namespaces of cloud services, see Cloud service monitoring metrics. |
acs_ecs_dashboard |
| MetricName |
string |
Yes |
The metric name of the cloud service. For information about metric names, see Cloud service monitoring 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 time. Two formats are supported: 1. A UNIX timestamp string in milliseconds (ms), which represents the number of milliseconds elapsed since 1970-01-01 00:00:00 UTC. 2. A time string in the ISO 8601 format of YYYY-MM-DDThh:mm:ssZ in UTC. Note
The query range uses a left-exclusive and right-inclusive mode. StartTime cannot be equal to or greater than EndTime, and the interval between them must be less than or equal to 31 days. |
2019-01-31 10:00:00 |
| EndTime |
string |
No |
The end time for querying the metric. The system automatically limits the query start time (query window size) based on data granularity:
Note
If the specified startTime is earlier than the limit, the system automatically uses the limit as the actual query start time. |
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 monitoring data. This parameter is used for paged query. Default value: 1000, which indicates 1000 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.