GetMetrics

Updated at:

Retrieves metrics data.

Operation description

Request description

  • This operation queries the monitoring metrics for a specific job (JobId) or dimension (Dimensions) under a specified namespace.

  • Supports a custom query time range. The default is the data from the last hour.

  • You can select different time intervals (Period) to obtain data points with finer or coarser granularity.

  • If you need to retrieve a large amount of data through paging, you can use the NextToken parameter for paging.

  • MetricName is required and specifies the name of the specific monitoring metrics to query.

  • For advanced features or specific types of monitoring metrics, refer to the relevant documentation for more information.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

paidlc:GetMetrics

none

*All Resource

*

None None

Request syntax

GET /api/v1/cms/metrics HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

Namespace

string

No

The data namespace of the cloud service. For more information about the data namespaces of cloud services, see Cloud service monitoring metrics.

acs_pai_dlc

JobId

string

No

The job ID.

dlckjd5hm84tmjec

Dimensions

string

No

(Required) The request parameters.

[{\"jobId\":\"dlcdpfpc96mh63mg\",\"pod\":\"dlcdpfpc96mh63mg-worker-748\",\"regionId\":\"cn-wulanchabu\",\"userId\":\"1458867964644701\"}]

Length

string

No

The size of each query, used for paging queries. Default value: 1000.

5000

EndTime

string

No

The end time of the query. Default value: the current time.

2020-11-09T16:00:00Z

Period

string

No

The statistical period of the monitoring data. Unit: seconds. Valid values: 15, 60, 900, and 3600.

5

NextToken

string

No

The pagination cursor. If this parameter is not specified, the first page of data is returned. If this parameter is returned in the response, it indicates that more data is available. You can use the returned NextToken value as the parameter in the next request to retrieve the next page of data until the returned value is null, which indicates that all data has been retrieved.

2c6b65b6f9d625d4716568ca19b2064be0b5e8707e68181f

MetricName

string

No

The metric name. This parameter is unpopulated and not in use.

JOB_MEMORY_FREE

StartTime

string

No

The start time of the time range for querying monitoring data in UTC. Default value: 1 hour ago.

2020-11-08T16:00:00Z

Token

string

No

The temporary token used for authentication.

eyXXXX-XXXX.XXXXX

Response elements

Element

Type

Description

Example

object

Schema of Response

NextToken

string

Id of the request

AAAAAV3MpHK1AP0pfERHZN5pu6lESTRpd5hnHNnmKOP/+w9F

Success

boolean

Indicates whether the operation was successful. Valid values: true: The operation was successful. false: The operation failed.

True

DataPoints

string

The monitoring metrics data.

[{'Content': '', 'OperationName': 'purchase', 'Success': 1, 'Id': '217', 'LogDatetime': 1687679582923}]

Code

string

The status code. A value of 200 indicates success.

200

Message

string

The detailed information about the detection result.

Success.

Period

string

The statistical period of the monitoring data. Valid values: 15, 60, 900, and 3600. Unit: seconds. If the statistical period is not specified, the monitoring data is queried based on the reporting period applied for when the monitoring metric was registered. The statistical period varies with the monitoring metric (MetricName) of each cloud service. For more information, see Cloud service monitoring metrics.

5

RequestId

string

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

Examples

Success response

JSON format

{
  "NextToken": "AAAAAV3MpHK1AP0pfERHZN5pu6lESTRpd5hnHNnmKOP/+w9F",
  "Success": true,
  "DataPoints": "[{'Content': '', 'OperationName': 'purchase', 'Success': 1, 'Id': '217', 'LogDatetime': 1687679582923}]",
  "Code": "200",
  "Message": "Success.",
  "Period": "5",
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.