Help Center/ Cloud Eye/ API Reference/ API V2/ Metric Management/ Batch Querying Metric Data
Updated on 2025-11-20 GMT+08:00

Batch Querying Metric Data

Function

This API is used to query metric data in batches.

Constraints

This API is supported in the following regions: CN East-Shanghai1, CN Southwest-Guiyang1, CN North-Ulanqab1, CN North-Beijing4, CN South-Guangzhou, CN North-Beijing1, CN South-Shenzhen, AP-Singapore, CN-Hong Kong, and CN East-Shanghai2.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

Authorization Information

Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.

  • If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    ces:metricData:list

    List

    -

    -

    -

    -

URI

POST /v2/{project_id}/batch-query-metric-data

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID. It is used to specify the project that an asset belongs to. You can query the assets of a project by project ID. You can obtain the project ID from the API or console. For details, see Obtaining a Project ID.

Constraints

N/A

Range

1 to 64 characters

Default Value

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

No

String

Definition

MIME type of the request body.

Constraints:

None

Value range:

The value can contain 1 to 64 characters.

Default value:

The default type is application/json; charset=UTF-8.

X-Auth-Token

No

String

Definition

User token.

Constraints:

None

Value range:

The value can contain 1 to 16,384 characters.

Default value:

None

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

namespace

Yes

String

Definition

Namespace of a service. For details about the namespace of each service, see Service Namespaces.

Constraints

N/A

Range

The value is in the service.item format. The values of service and item must be a string, starting with a letter and containing only digits (0–9), letters (case-insensitive), and underscores (_). It must contain 3 to 32 characters.

Default Value

N/A

metric_name

Yes

String

Definition

Metric name of a resource. For details about the metrics of each service, see Service Metric Names.

Constraints

N/A

Range

The value must start with a letter and can only contain digits, letters, underscores (_), and hyphens (-). It allows 1 to 64 characters. For example, the ECS metric cpu_util indicates the CPU usage of an ECS. The DDS metric mongo001_command_ps indicates the command execution frequency.

Default Value

N/A

metric_dimension

Yes

String

Definition

Metric dimension. Multiple dimensions are separated by commas (,).

Constraints

N/A

Range

The value must start with a letter and can only contain digits, letters, underscores (_), hyphens (-), and commas (,). Each dimension must start with a letter and allows 1 to 32 characters. Multiple dimensions are separated by commas (,).

Default Value

N/A

from

No

Long

Definition

Start time for querying monitoring data. The value is a timestamp in milliseconds.

Constraints

from must be earlier than to, and the interval between to and from must be within 5 minutes.

Range

Minimum: 0

Default Value

N/A

to

No

Long

Definition

End time for querying monitoring data. The value is a timestamp in milliseconds.

Constraints

from must be earlier than to, and the interval between to and from must be within 5 minutes.

Range

Minimum: 0

Default Value

N/A

limit

No

Integer

Definition

Number of records displayed on each page.

Constraints

N/A

Range

1 to 1000

Default Value

100

offset

No

Integer

Definition

Pagination offset.

Constraints

N/A

Range

0 to 9999999

Default Value

0

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

namespace

String

Definition

Namespace of a service. For details about the namespace of each service, see Service Namespaces.

Range

The value is in the service.item format. The values of service and item must be a string, starting with a letter and containing only digits (0–9), letters (case-insensitive), and underscores (_). It must contain 3 to 32 characters.

metric_name

String

Definition

Metric name of a resource. For details about the metrics of each service, see Service Metric Names.

Range

The value must start with a letter and can only contain digits, letters, underscores (_), and hyphens (-). 1 to 96 characters For example, the ECS metric cpu_util indicates the CPU usage of an ECS. The DDS metric mongo001_command_ps indicates the command execution frequency.

metric_dimension

String

Definition

Metric dimension. Multiple dimensions are separated by commas (,).

Range

The value must start with a letter and can only contain digits, letters, underscores (_), hyphens (-), and commas (,). Each dimension must start with a letter and allows 1 to 32 characters. Multiple dimensions are separated by commas (,).

data_points

Array of MetricDataPoint objects

Definition

Monitoring data list.

Table 5 MetricDataPoint

Parameter

Type

Description

dimensions

Array of dimensions objects

Definition

Dimension information.

timestamp

Integer

Definition

Metric collection time.

Range

Minimum: 0.

value

Double

Definition

Metric value.

Range

N/A

unit

String

Definition

Data unit.

Range

[0,32]

Table 6 dimensions

Parameter

Type

Description

name

String

Definition

Metric dimension value.

Range

1 to 32 characters

value

String

Definition

Metric dimension value.

Range

1 to 256 characters

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Status codes customized by each cloud service when a request error occurs.

error_msg

String

Request error message.

request_id

String

Request ID.

Status code: 401

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Status codes customized by each cloud service when a request error occurs.

error_msg

String

Request error message.

request_id

String

Request ID.

Status code: 403

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Status codes customized by each cloud service when a request error occurs.

error_msg

String

Request error message.

request_id

String

Request ID.

Status code: 500

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

Status codes customized by each cloud service when a request error occurs.

error_msg

String

Request error message.

request_id

String

Request ID.

Example Requests

Querying the monitoring data of the disk_agt_write_bytes_rate metric whose dimension is instance_id,disk. The monitoring data was collected from 16:50:00 to 16:55:00 on November 14, 2024, with two records on each page.

/v2/d946d6a5b221400185e9db592a5329c6/batch-query-metric-data

{
  "namespace" : "AGT.ECS",
  "metric_name" : "disk_agt_write_bytes_rate",
  "metric_dimension" : "instance_id,disk",
  "from" : 1731574200000,
  "to" : 1731574500000,
  "limit" : 2,
  "offset" : 0
}

Example Responses

Status code: 200

OK. Response body for querying metric data in batches.

{
  "namespace" : "AGT.ECS",
  "metric_name" : "disk_agt_write_bytes_rate",
  "metric_dimension" : "instance_id,disk",
  "data_points" : [ {
    "dimensions" : [ {
      "name" : "disk",
      "value" : "2e84018fc8b4484b94e89aae212fe615",
      "origin_value" : "vda"
    }, {
      "name" : "instance_id",
      "value" : "57259492-54c8-475c-8bff-1c3c60d9ed4e"
    } ],
    "timestamp" : 1731574202332,
    "value" : 4232.53,
    "unit" : "Byte/s"
  }, {
    "dimensions" : [ {
      "name" : "disk",
      "value" : "2e84018fc8b4484b94e89aae212fe615",
      "origin_value" : "vda"
    }, {
      "name" : "instance_id",
      "value" : "8f3058e2-64aa-42d7-ba68-9df1cee811db"
    } ],
    "timestamp" : 1731574206166,
    "value" : 17885.87,
    "unit" : "Byte/s"
  } ]
}

Status Codes

Status Code

Description

200

OK. Response body for querying metric data in batches.

400

The server failed to process the request.

401

Token authentication is required.

403

Access to the requested page is forbidden.

500

Failed to complete the request because of an internal server error.

Error Codes

See Error Codes.