Queries the latest monitoring data of a metric.

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.

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

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, respectively.

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 DescribeMetricLast

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

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 CPUUtilization

The metric that is used to monitor the cloud service.

For more information about metric names, 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
  • If this parameter is not specified, monitoring data is queried based on the period in which metric values are reported.
  • Statistical periods vary based on the metrics that are specified by MetricName. For more information, see Appendix 1: Metrics.
StartTime String No 2019-01-31 10:00:00

The start of the time range to query monitoring data.

EndTime String No 2019-01-31 10:10:00

The end of the time range to query monitoring data.

  • For second-level data, the start time is obtained by comparing the time that is specified by the StartTime parameter and 20 minutes earlier of the time that is specified by the EndTime parameter. The earlier one of the compared points in time is used as the start time.
  • For minute-level data, the start time is obtained by comparing the time that is specified by the StartTime parameter and 2 hours earlier of the time that is specified by the EndTime parameter. The earlier one of the compared points in time is used as the start time.
  • For hour-level data, the start time is obtained by comparing the time that is specified by the StartTime parameter and two days earlier of the time that is specified by the EndTime parameter. The earlier one of the compared points in time is used as the start time.
Dimensions String No [{"instanceId":"i-2ze2d6j5uhg20x47****"}]

The monitoring dimensions of the specified resource.

Set the value to a collection of key:value pairs. Example: {"userId":"120886317861****"} or {"instanceId":"i-2ze2d6j5uhg20x47****"}.

Note You can query a maximum of 50 instances in a single request.
NextToken String No 15761432850009dd70bb64cff1f0fff6c0b08ffff073be5fb1e785e2b020f7fed9b5e137bd810a6d6cff5ae****

The pagination token.

  • If the number of results exceeds the maximum number of entries allowed on a single page, a pagination token is returned.
  • This token can be used as an input parameter to obtain the next page of results. If all results are obtained, no token is returned.
Length String No 1000

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 in a request is 1440.
Express String No {"groupby":["userId","instanceId"]}

The expression that is used to calculate the query results in real time.

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

Response parameters

Parameter Type Example Description
NextToken String xxxxxx

The pagination token.

RequestId String 021472A6-25E3-4094-8D00-BA4B6A5486C3

The request ID.

Success Boolean true

Indicates whether the request was successful. Valid values:

  • true
  • false
Datapoints String [{"timestamp":1548777660000,"userId":"123456789876****","instanceId":"i-abcdefgh12****","Minimum":93.1,"Average":99.52,"Maximum":100}]

The monitoring data.

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.

Period String 60

The time interval.

Unit: seconds.

Examples

Sample requests

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

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<QueryMetricListResponse>
	<Period>60</Period>
	<Datapoints>
		<timestamp>1548777660000</timestamp>
		<Maximum>100</Maximum>
		<userId>123456789876****</userId>
		<Minimum>93.1</Minimum>
		<instanceId>i-abcdefgh12****</instanceId>
		<Average>99.52</Average>
	</Datapoints>
	<RequestId>6A5F022D-AC7C-460E-94AE-B9E75083D027</RequestId>
	<Success>true</Success>
	<Code>200</Code>
</QueryMetricListResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "Period" : "60",
  "Datapoints" : [ {
    "timestamp" : 1548777660000,
    "Maximum" : 100,
    "userId" : "123456789876****",
    "Minimum" : 93.1,
    "instanceId" : "i-abcdefgh12****",
    "Average" : 99.52
  } ],
  "RequestId" : "6A5F022D-AC7C-460E-94AE-B9E75083D027",
  "Success" : true,
  "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.