• Cloud Eye

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

Adding Monitoring Data

Function

This API is used to add one or multiple pieces of metric monitoring data.

URI

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

  • Parameter description
    Table 1 Parameter description

    Parameter

    Description

    project_id

    Indicates the project ID.

  • Example
    /V1.0/{project_id}/metric-data

Request

  1. The size of a POST request cannot exceed 512 KB. Otherwise, the request will be denied.
  2. The period for sending POST requests must be shorter than the minimum aggregation period. Otherwise, the aggregated data will be noncontinuous. For example, if the aggregation period is 5 minutes and the POST request sending period is 7 minutes, the data will be aggregated every 10 minutes, rather than 5 minutes.
  3. Timestamp (collect_time) in the POST request body value must be within the period that starts from three days before the current time to 10 minutes after the current time. If it is not in this range, you are not allowed to insert the metric data.
  • Request parameters
    Table 2 Request parameters

    Parameter

    Mandatory

    Type

    Description

    metric

    Yes

    JSON object

    Indicates the metric data.

    namespace

    Yes

    String

    Indicates the namespace, such as ECS Namespace. Indicates the namespace in 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 (_). In addition, service cannot be set to SYS.

    namespace cannot be AGT.ECS or SERVICE.BMS.

    metric_name

    Yes

    String

    The value can be a string of 1 to 64 characters and must start with a letter and contain only uppercase letters, lowercase letters, digits, and underscores (_).

    dimensions

    Yes

    JSON array

    Indicates the list of the metric dimensions.

    Each dimension is a JSON object, and its structure is as follows:

    • dimension.name: indicates the dimension name. The value can be a string of 1 to 32 characters and must start with a letter and contain only uppercase letters, lowercase letters, digits, underscores (_), and hyphens (-).
    • dimension.value: indicates the dimension value. The value can be a string of 1 to 256 characters and must start with a letter or a digit and contain only uppercase letters, lowercase letters, digits, underscores (_), and hyphens (-).

    ttl

    Yes

    Number

    Indicates the data validity period in seconds.

    The maximum value is 604800.

    If the validity period expires, the data will be automatically deleted.

    collect_time

    Yes

    UNIX timestamp

    Indicates the time when the data was collected.

    The time is UNIX timestamp (ms) format.

    NOTE:

    Since there is a latency between the client and the server, the data timestamp to be inserted should be within the period that starts from three days before the current time plus 20s to 10 minutes after the current time minus 20s. In this way, the timestamp will be inserted to the database without being affected by the latency.

    value

    Yes

    Number

    Indicates the metric value.

    unit

    No

    String

    Indicates the data unit.

    NOTE:

    Enter a maximum of 32 characters.

    type

    No

    String

    Indicates the data type.

    The value can only be int or float.

  • Example request
    [
        {
            "metric": {
                "namespace": "MINE.APP",
                "dimensions": [
                    {
                        "name": "instance_id",
                        "value": "33328f02-3814-422e-b688-bfdba93d4050"
                    }
                ],
                "metric_name": "cpu_util"
            },
            "ttl": 172800,
            "collect_time": 1463598260000,
            "value": 60,
            "unit": "%"
        },
        {
            "metric": {
                "namespace": "MINE.APP",
                "dimensions": [
                    {
                        "name": "instance_id",
                        "value": "33328f02-3814-422e-b688-bfdba93d4050"
                    }
                ],
                "metric_name": "cpu_util"
            },
            "ttl": 172800,
            "collect_time": 1463598270000,
            "value": 70,
            "unit": "%"
        }
    ]

Response

The response has no message body.

Returned Values

  • Normal

    201

  • Abnormal

    Returned Value

    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.