Updated on 2026-10-22 GMT+08:00

Querying Metrics

Function

This API is used to query metrics. You can specify the namespace, metric name, dimension, sorting order, starting record, and the maximum number of records to filter the query results.

After a cloud service resource is deleted, its data remains cached for 3 hours. During this period, metrics of the resource can still be queried.

Calling Method

For details, see Calling APIs.

URI

GET /V1.0/{project_id}/metrics

Table 1 Parameter description

Parameter

Type

Mandatory

Description

project_id

String

Yes

Specifies a project ID. You can obtain the project ID by referring to Obtaining the Project ID.

Table 2 Query parameters

Parameter

Type

Mandatory

Description

namespace

String

No

  • Specifies the service metric namespace.
  • The namespace of Enterprise Edition VPN is SYS.VPN.

metric_name

String

No

  • Specifies a metric ID. For details about metrics, see Metrics (S2C Enterprise Edition VPN) and Metrics (P2C VPN).
  • The value is a string of 1 to 96 characters. It must start with a letter and can contain only digits, letters, underscores (_), and hyphens (-). For example, the metric ID for the inbound packet rate of a VPN gateway is gateway_recv_pkt_rate.

dim

String

No

  • Specifies the dimension of a metric. For metrics with hierarchical dimensions, perform queries using multi-level dimensions.
  • A maximum of four dimension levels are supported, starting from index 0. Index 3 represents the deepest level.
  • The value is in the format dim.{i}=key,value. The maximum length of key is 32 characters, and the maximum length of value is 256 characters.

    The following provides dimension examples. For more information about dimensions, see Metrics (S2C Enterprise Edition VPN) and Metrics (P2C VPN).

    • Single-level dimension: For example, the metric gateway_connection_num (number of connections) for a P2C VPN gateway uses the dimension p2c_vpn_gateway_id at level 0. An example of the dimension information is as follows:

      dim.0=p2c_vpn_gateway_id,4ae00000-0000-0000-0000-0000b1428ef4

    • Multi-level dimension: For example, the metric sa_send_pkt_rate (SA packet send rate) for an S2C VPN connection uses the dimension evpn_sa_id at level 1, with the upper-level dimension being evpn_connection_id at level 0. An example of the dimension information is as follows:

      dim.0=evpn_connection_id,4ae00000-0000-0000-0000-0000b1428ef5&dim.1=evpn_sa_id,4ae00000-0000-0000-0000-0000b1428ef6

start

String

No

  • Specifies the start flag for querying the current page. If this parameter is left blank, the first page is queried.
  • The value is in the format namespace.metric_name.key:value, for example, start=SYS.VPN.gateway_connection_num.p2c_vpn_gateway_id:4ae0bd2d-a5fb-4155-9775-4eb1b1428ef4.index:756529722.

limit

Integer

No

  • Specifies the number of records returned on each page during pagination query.
  • The value range is [1, 1000].
  • The default value is 1000.

order

String

No

  • Specifies how results are sorted by timestamp.
  • The value can be asc (ascending) or desc (descending).
  • The default value is asc.

Request

  • Request parameters

    None

  • Example request
    Example request 1: Query all metrics that can be monitored.
    GET https://{Cloud Eye endpoint}/V1.0/{project_id}/metrics

    Example request 2: Query the connection count of the P2C VPN gateway whose ID is 4ae00000-0000-0000-0000-0000b1428ef7, and return 10 records sorted by timestamp in descending order.

    GET https://{Cloud Eye endpoint}/V1.0/{project_id}/metrics?namespace=SYS.VPN&metric_name=gateway_connection_num&dim.0=p2c_vpn_gateway_id,4ae00000-0000-0000-0000-0000b1428ef7&limit=10&order=desc

Response

  • Response parameters

    Returned status code 200: successful query

    Table 3 Parameters in the response body

    Parameter

    Type

    Description

    metrics

    Array of Metrics objects

    Specifies metrics.

    meta_data

    MetaData object

    Specifies the metadata of query results, including pagination information.

    Table 4 Metrics

    Parameter

    Type

    Description

    namespace

    String

    Specifies the namespace to which a metric belongs.

    dimensions

    Array of Dimensions objects

    Specifies metric dimensions.

    metric_name

    String

    Specifies a metric name, for example, gateway_connection_num.

    unit

    String

    Specifies the unit of the metric.

    Table 5 Dimensions

    Parameter

    Type

    Description

    name

    String

    Specifies a dimension name.

    value

    String

    Specifies a dimension value, for example, the ID of a P2C VPN gateway.

    Table 6 MetaData

    Parameter

    Type

    Description

    count

    Integer

    Specifies the number of returned records.

    marker

    String

    Specifies the start flag for querying the current page. If this parameter is left blank, the first page is queried. The marker for querying the next page is the marker in the meta_data object returned on the current page.

    total

    Integer

    Specifies the total number of records in the metric query result.

  • Example response
    {
        "metrics": [
            {
                "namespace": "SYS.VPN",
                "dimensions": [
                    {
                        "name": "p2c_vpn_gateway_id",
                        "value": "72fe0000-0000-0000-0000-0000f0efd460"
                    }
                ],
                "metric_name": "gateway_connection_num",
                "unit": "count"
            }
        ],
        "meta_data": {
            "count": 1,
            "marker": "SYS.VPN.gateway_connection_num.p2c_vpn_gateway_id:72fe0000-0000-0000-0000-0000f0efd460.index:756558082",
            "total": 16
        }
    }

Status Codes

For details, see Status Codes.