Queries the monitoring data of a metric for a specified cloud service.
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 queried 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.
Usage notes
Dimension
parameter to {"instanceId": "i-abcdefgh12****"} to aggregate all data of your Alibaba Cloud account. This topic provides an example on how to query the monitoring data of the cpu_idle
metric for Elastic Compute Service (ECS). The namespace of ECS is acs_ecs_dashboard
.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | DescribeMetricData | The operation that you want to perform. Set the value to DescribeMetricData. |
Namespace | String | Yes | acs_ecs_dashboard | The namespace of the cloud service. For more information about the namespaces of cloud services, see Appendix 1: Metrics. |
MetricName | String | Yes | cpu_idle | The metric that is used to monitor the cloud service. For more information about the metrics of cloud services, see Appendix 1: Metrics. |
Period | String | No | 60 | The statistical period of the monitoring data. Valid values: 15, 60, 900, and 3600. Unit: seconds. Note
|
StartTime | String | No | 1618368900000 | The start of the time range to query monitoring data.
The following formats are supported:
Note
|
EndTime | String | No | 1618368960000 | 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. |
Dimensions | String | No | [{"instanceId":"i-2ze2d6j5uhg20x47****"}] | The monitoring dimensions of the specified resource. Set the value to a collection of Note You can query a maximum of 50 instances in a single request. |
Express | String | No | {"groupby":["userId","instanceId"]} | 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 that is used in databases. |
Length | String | No | 1000 | The number of entries per page. Default value: 1000. Note The maximum value of the Length parameter in a request is 1440. |
For more information about common request parameters, see Common parameters.
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
Code | String | 200 | The status code. Note The status code 200 indicates that the request was successful. |
Message | String | The specified resource is not found. | The error message. |
RequestId | String | 6A5F022D-AC7C-460E-94AE-B9E75083D027 | The request ID. |
Datapoints | String | [{\"timestamp\":1618368900000,\"Average\":95.8291666666667,\"Minimum\":65.48,\"Maximum\":100.0},{\"timestamp\":1618368960000,\"Average\":95.8683333333333,\"Minimum\":67.84,\"Maximum\":100.0}] | The monitoring data. The value includes the following fields:
|
Period | String | 60 | The statistical period of the monitoring data. Valid values: 15, 60, 900, and 3600. Unit: seconds. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=DescribeMetricData
&MetricName=cpu_idle
&Namespace=acs_ecs_dashboard
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<DescribeMetricDataResponse>
<RequestId>7598FEED-3B79-4B4A-AD01-435F34DA8EDC</RequestId>
<Period>60</Period>
<Datapoints>[{\"timestamp\":1618368900000,\"Average\":95.8291666666667,\"Minimum\":65.48,\"Maximum\":100.0},{\"timestamp\":1618368960000,\"Average\":95.8683333333333,\"Minimum\":67.84,\"Maximum\":100.0}]</Datapoints>
<Code>200</Code>
</DescribeMetricDataResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "7598FEED-3B79-4B4A-AD01-435F34DA8EDC",
"Period" : "60",
"Datapoints" : "[{\"timestamp\":1618368900000,\"Average\":95.8291666666667,\"Minimum\":65.48,\"Maximum\":100.0},{\"timestamp\":1618368960000,\"Average\":95.8683333333333,\"Minimum\":67.84,\"Maximum\":100.0}]",
"Code" : "200"
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
404 | ResourceNotFound | The specified resource is not found. | The specified resource is not found. |
For a list of error codes, see Service error codes.