All Products
Search
Document Center

CloudMonitor:DescribeMetricLast

Last Updated:Jul 26, 2024

Queries the latest monitoring data of a metric.

Operation description

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.

Note If Throttling.User or Request was denied due to user flow control is returned when you call an API operation, the API operation is throttled. For more information about how to handle the issue, see How do I handle the throttling of a query API?

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

Description

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.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
cms:QueryMetricLastget
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
NamespacestringYes

The namespace of the cloud service.

For more information about the namespaces of cloud services, see Appendix 1: Metrics.

acs_ecs_dashboard
MetricNamestringYes

The metric that is used to monitor the cloud service.

For more information about metric names, see Appendix 1: Metrics.

CPUUtilization
PeriodstringNo

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. The statistical period of metrics (MetricName) varies for each cloud service. The statistical period of metrics is displayed in the MinPeriods column on the Metrics page for each cloud service. For more information, see Appendix 1: Metrics.
60
StartTimestringNo

The start of the time range to query monitoring data.

2019-01-31 10:00:00
EndTimestringNo

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.
2019-01-31 10:10:00
DimensionsstringNo

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 each request.
[{"instanceId":"i-abcdefgh12****"}]
NextTokenstringNo

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.
15761432850009dd70bb64cff1f0fff6c0b08ffff073be5fb1e785e2b020f7fed9b5e137bd810a6d6cff5ae****
LengthstringNo

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 for each request is 1440.
1000
ExpressstringNo

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

{"groupby":["userId","instanceId"]}

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

Response parameters

ParameterTypeDescriptionExample
object
NextTokenstring

The pagination token.

xxxxxx
RequestIdstring

The request ID.

021472A6-25E3-4094-8D00-BA4B6A5486C3
Successboolean

Indicates whether the request was successful. Valid values:

  • true
  • false
true
Datapointsstring

The monitoring data.

[{"timestamp":1548777660000,"userId":"123456789876****","instanceId":"i-abcdefgh12****","Minimum":93.1,"Average":99.52,"Maximum":100}]
Codestring

The HTTP status code.

Note The status code 200 indicates that the request was successful.
200
Messagestring

The error message.

The specified resource is not found.
Periodstring

The time interval.

Unit: seconds.

60

Examples

Sample success responses

JSONformat

{
  "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 codeError codeError messageDescription
400ParameterInvalidIllegal parameters.-
403AccessForbiddenUser not authorized to operate on the specified resource.-
404ResourceNotFoundThe specified resource is not found.The specified resource is not found.
500InternalErrorThe request processing has failed due to some unknown error.-

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
No change history