Adding Monitoring Data

Function

This API is used to add one or more monitoring data records to a server.

URI

POST /v1/{project_id}/ams/report/metricdata

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID obtained from IAM. Generally, a project ID contains 32 characters.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token obtained from IAM.

Content-Type

Yes

String

Content type, which is application/json.

Enumeration values:

  • application/json

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

[items]

Yes

Array of MetricDataItem objects

Metric parameters.

Table 4 MetricDataItem

Parameter

Mandatory

Type

Description

collect_time

Yes

Long

Data collection time (UNIX timestamp, in ms), which ranges from the last 24 hours to the next 0.5 hour. The following requirement needs to be met: Current UTC time – Data collection time ≤ 24 hours, or Data collection time – Current UTC time ≤ 30 minutes If the data reporting time is earlier than 08:00 of the current day, only the data generated after 08:00 of the current day is displayed on the metric monitoring page.

metric

Yes

MetricItemInfo object

Metric details.

values

Yes

Array of ValueData objects

Metric value.

Table 5 MetricItemInfo

Parameter

Mandatory

Type

Description

dimensions

Yes

Array of Dimension2 objects

List of metric dimensions. Each dimension is a JSON object composed of the following: dimension.name: 1–32 characters. dimension.value: 1–64 characters.

namespace

Yes

String

Metric namespace, which must be in the format of service.item. The value must be 3 to 32 characters starting with a letter. Only letters, digits, and underscores (_) are allowed. In addition, service cannot be PAAS.

Minimum: 3

Maximum: 32

Table 6 Dimension2

Parameter

Mandatory

Type

Description

name

Yes

String

Name.

Minimum: 1

Maximum: 32

value

Yes

String

Metric value.

Minimum: 1

Maximum: 64

Table 7 ValueData

Parameter

Mandatory

Type

Description

metric_name

Yes

String

Metric name.

type

No

String

Data type. Values: int and float.

Enumeration values:

  • int

  • float

unit

No

String

Data unit.

value

Yes

Double

Metric value, which must be of a valid numeric type.

Minimum: 0

Response Parameters

Status code: 200

Table 8 Response body parameters

Parameter

Type

Description

errorCode

String

Response code.

Minimum: 12

Maximum: 12

errorMessage

String

Response message.

Example Requests

Add a piece of monitoring data to the server. (In the following example, set "collect_time" to the latest timestamp.)

https://{Endpoint}/v1/{project_id}/ams/report/metricdata

[ {
  "metric" : {
    "namespace" : "NOPAAS.ESC",
    "dimensions" : [ {
      "name" : "instance_id",
      "value" : "instance-101"
    } ]
  },
  "values" : [ {
    "unit" : "percent",
    "metric_name" : "cpu_util",
    "type" : "int",
    "value" : 35
  } ],
  "collect_time" : 1467787152000
} ]

Example Responses

Status code: 200

The request is successful.

{
  "errorCode" : "SVCSTR.ALS.200200",
  "errorMessage" : "success"
}

Status Codes

Status Code

Description

200

The request is successful.

400

Invalid request.

401

Invalid authentication information.

403

The request is rejected.

500

The server is able to receive the request, but the request is improper.

503

The service is unavailable.

Error Codes

See Error Codes.