Queries the monitoring data of a metric of a specified cloud service.

Note Different from DescribeMetricList, the DescribeMetricData operation provides statistical features. You can set the Dimension parameter to {"userId:"xxxx"} to aggregate all data of the specified user.

This topic provides an example of how to query the cpu_idle metric of the acs_ecs_dashboard cloud service.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes DescribeMetricData

The operation that you want to perform. Set the value to DescribeMetricData.

MetricName String Yes cpu_idle

The name of the metric. For more information, see Appendix 1: Metrics.

Namespace String Yes acs_ecs_dashboard

The namespace of the cloud service. For more information, see Appendix 1: Metrics.

Period String No 60

The interval at which the monitoring data is queried. Unit: seconds. Valid values: 60, 300, and 900.

StartTime String No 1618368900000

The beginning of the time range to query. Supported formats:

  • UNIX timestamp: the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.
  • Time format: YYYY-MM-DDThh:mm:ssZ.
Note
  • The specified period includes the end time and excludes the start time. The start time must be earlier than the end time.
  • We recommend that you use UNIX timestamps to prevent time zone-related issues.
EndTime String No 1618368960000

The end of the time range to query. Supported formats:

  • UNIX timestamp: the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.
  • Time format: YYYY-MM-DDThh:mm:ssZ.
    Note We recommend that you use UNIX timestamps to prevent time zone-related issues.
Dimensions String No [{"instanceId": "i-abcdefgh12****"}]

The dimensions that specify the resources for which you want to query monitoring data.

Set the value to a collection of key-value pairs. A typical key-value pair is instanceId:XXXXXX.

The key-value pairs can be 1 to 64 bytes in length. Excessive characters are truncated.

The keys and values can contain letters, digits, periods (.), hyphens (-), underscores (_), forward slashes (/), and backslashes (\).

Note Dimensions must be formatted as a JSON string in a specified order.
Express String No null

The expression for real-time computation on the query results.

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 to return on each page.

For more information about common request parameters, see Common parameters.

Response parameters

Parameter Type Example Description
Code String 200

The HTTP status code.

Note The value 200 indicates that the call was successful.
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:

  • timestamp: the timestamp when the alert was triggered.
  • userId: the ID of the user for which the alert was triggered.
  • instanceId: the ID of the instance for which the alert was triggered.
  • Minimum, Average, and Maximum: the aggregation methods.
Message String The specified resource is not found.

The returned message.

Period String 60

The interval at which the monitoring data was queried. Unit: seconds. Valid values: 60, 300, and 900.

RequestId String 6A5F022D-AC7C-460E-94AE-B9E75083D027

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/?Action=DescribeMetricData
&MetricName=cpu_idle
&Namespace=acs_ecs_dashboard
&<Common request parameters>

Sample success response

XML format

<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

{
	"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 error message returned because the specified resource is not found.

For a list of error codes, visit the API Error Center.