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. A maximum of 50 dimensions are supported. Each dimension is in JSON format. The structure is as follows: dimension.name: 1-32 characters. dimension.value: 1-64 characters.

namespace

Yes

String

Metric namespace. It cannot contain colons (:). It must be in the format of "service.item". The value must contain 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

Dimension name.

Minimum: 1

Maximum: 32

value

Yes

String

Dimension value.

Minimum: 1

Maximum: 64

Table 7 ValueData

Parameter

Mandatory

Type

Description

metric_name

Yes

String

Metric name. Length: 1 to 255 characters.

type

No

String

Data type. Values: int and float.

Enumeration values:

  • int

  • float

unit

No

String

Data unit. Length: up to 32 characters.

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.

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

OK: The request is successful.

{
  "errorCode" : "SVCSTG_AMS_2000000",
  "errorMessage" : "success"
}

Status Codes

Status Code

Description

200

OK: The request is successful.

400

Bad Request: The request is invalid. The client should not repeat the request without modifications.

401

Unauthorized: The authentication information is incorrect or invalid.

403

Forbidden: The request is rejected. The server has received the request and understood it, but the server refuses to respond to it. The client should not repeat the request without modifications.

500

Internal Server Error: The server is able to receive the request but unable to understand the request.

503

Service Unavailable: The requested service is invalid. The client should not repeat the request without modifications.

Error Codes

See Error Codes.