• Cloud Eye

ces
  1. Help Center
  2. Cloud Eye
  3. API Reference
  4. API Description
  5. Monitoring Data Management
  6. Querying Monitoring Data

Querying Monitoring Data

Function

This API is used to query the monitoring data at a specified granularity for a specified metric in a specified period of time. You can specify the dimension of data to be queried.

URI

GET /V1.0/{project_id}/metric-data

  • Parameter description
    Table 1 Parameter description

    Parameter

    Description

    project_id

    Indicates the project ID.

    Table 2 Query parameter description

    Parameter

    Mandatory

    Type

    Description

    namespace

    Yes

    String

    Indicates the namespace, such as ECS Namespace.

    metric_name

    Yes

    String

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

    from

    Yes

    Timestamp

    Indicates the start time of the query.

    The value is a UNIX timestamp and the unit is ms.

    Set the value of from to at least one period earlier than the current time.

    Rollup aggregates the raw data generated within a period to the start time of the period. Therefore, if values of from and to are within a period, the query result will be empty due to the rollup failure.

    Take the 5-minute period as an example. If it is 10:35 now, the raw data generated between 10:30 and 10:35 will be aggregated to 10:30. Therefore, in this example, if the value of period is 5 minutes, the value of from should be 10:30 or earlier.

    NOTE:

    Cloud Eye rounds up the value of from based on the level of granularity required to perform the rollup.

    to

    Yes

    Timestamp

    Indicates the end time of the query.

    The value is a UNIX timestamp and the unit is ms.

    The value of parameter from must be earlier than that of parameter to.

    period

    Yes

    Enumerated

    Indicates the data monitoring granularity.

    The value can be:

    • 1: The data is monitored in real time.
    • 300: The data monitoring granularity is 5 minutes.
    • 1200: The data monitoring granularity is 20 minutes.
    • 3600: The data monitoring granularity is 1 hour.
    • 14400: The data monitoring granularity is 4 hours.
    • 86400: The data monitoring granularity is 1 day.

    filter

    Yes

    String

    Indicates the data rollup method.

    The value can be Max., Min., Avg., Sum, or Variance.

    dim

    Yes

    String

    Currently, a maximum of three metric dimensions are supported, and the dimensions are numbered from 0 in the dim.{i}=key,value format. The key value can not exceed 32 characters and the value value cannot exceed 256 characters.

    For example, the value can be dim.0=instance_id,i-12345.

  • Example
    /V1.0/{project_id}/metric-data?namespace=SYS.ECS&metric_name=cpu_util&dim.0=instance_id,6f3c6f91-4b24-4e1b-b7d1-a94ac1cb011d&from=1442347449274&to=1442390649274&period=1200&filter=min

Request

None

Response

  • Response parameters
    Table 3 Response parameters

    Parameter

    Type

    Description

    datapoints

    JSON array

    Indicates the metric data list.

    Since Cloud Eye rounds up the value of from based on the level of granularity for data query, datapoints may contain more data points than expected.

    max/min/average/sum/variance

    Number

    Indicates the metric value.

    The value of this parameter is the same as that of parameter filter.

    timestamp

    Timestamp

    Indicates the metric collection time.

    unit

    String

    Indicates the metric unit.

    metric_name

    String

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

  • Example response
    {
        "datapoints": [
            {
                "average": 0, 
                "timestamp": 1442341200000, 
                "unit": "Count"
            }
        ], 
        "metric_name": "cpu_util"
    }

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.