• Cloud Eye

ces
  1. Help Center
  2. Cloud Eye
  3. API Reference
  4. API Description
  5. Metric Management
  6. Querying the Metric List

Querying the Metric List

Function

This API is used to query the metric list. You can specify the namespace, metric, dimension, sorting order, start records, and the maximum number of records when using this API to query metrics.

URI

GET /V1.0/{project_id}/metrics

  • Parameter description
    Table 1 Parameter description

    Parameter

    Description

    project_id

    Indicates the project ID.

    Table 2 Query parameter description

    Parameter

    Mandatory

    Type

    Description

    namespace

    No

    String

    Indicates the namespace, such as ECS Namespace. Its value must use the service.item format. service and item each can be a string of 3 to 32 characters and must start with a letter and contain only uppercase letters, lowercase letters, digits, and underscores (_).

    metric_name

    No

    String

    Indicates the metric name, such as cpu_util in ECS Metrics.

    dim

    No

    String

    Indicates the metric dimension, such as instance_id in ECS Dimension.

    A maximum of three dimensions are supported, and the dimensions are numbered from 0 in dim.{i}=key,value format.

    The key cannot exceed 32 characters and the value cannot exceed 256 characters.

    For example, dim.0=instance_id,6f3c6f91-4b24-4e1b-b7d1-a94ac1cb011d

    start

    No

    String

    Indicates the paging start value.

    The format is namespace.metric_name.key:value.

    For example, start=SYS.ECS.cpu_util.instance_id:d9112af5-6913-4f3b-bd0a-3f96711e004d.

    limit

    No

    Integer

    The value ranges from 1 to 1000, and is 1000 by default.

    This parameter is used to limit the number of query results.

    order

    No

    Enumerated

    Indicates the result sorting method, which is sorted by timestamp.

    The default value is desc.

    • asc: The query results are displayed in the ascending order.
    • desc: The query results are displayed in the descending order.
  • Example
    /V1.0/{project_id}/metrics
    /V1.0/{project_id}/metrics?namespace=SYS.ECS&metric_name=cpu_util&dim.0=instance_id,6f3c6f91-4b24-4e1b-b7d1-a94ac1cb011d&limit=10&order=desc

Request

None

Response

  • Response parameters
    Table 3 Response parameters

    Parameter

    Type

    Description

    meta_data

    JSON object

    Indicates the metadata of query results, including the paging information.

    meta_data.count

    Integer

    Indicates the number of returned results.

    meta_data.total

    Integer

    Indicates the total number of query results.

    meta_data.marker

    String

    Indicates the pagination marker.

    metrics

    JSON array

    Indicates the list of metric objects.

    namespace

    String

    Indicates the metric namespace.

    metric_name

    String

    Indicates the metric name, such as cpu_util.

    unit

    String

    Indicates the metric unit.

    dimensions

    JSON array

    Indicates the list of the metric dimensions.

    dimension.name: indicates the object type, for example, ECS (instance_id).

    dimension.value: indicates the object ID, for example, ECS ID. The value is a string of one to 256 characters.

  • Example response
    {
        "metrics": [
            {
                "namespace": "SYS.ECS", 
                "dimensions": [
                    {
                        "name": "instance_id", 
                        "value": "d9112af5-6913-4f3b-bd0a-3f96711e004d"
                    }
                ], 
                "metric_name": "cpu_util", 
                "unit": "%"
            }
        ], 
        "meta_data": {
            "count": 1, 
            "marker": "SYS.ECS.cpu_util.instance_id:d9112af5-6913-4f3b-bd0a-3f96711e004d", 
            "total": 7
        }
    }

Returned Values

  • Normal

    200

  • Abnormal

    Returned Values

    Description

    400 Bad Request

    Request error

    401 Unauthorized

    The authentication information is not provided or is incorrect.

    403 Forbidden

    You are forbidden to access the page requested.

    408 Request Timeout

    The request timed out.

    429 Too Many Requests

    Concurrent requests are excessive.

    500 Internal Server Error

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

    503 Service Unavailable

    The service is currently unavailable.

Error Code

For details, see Error Codes.