Adding Monitoring Data
Function
This API is used to add one or more pieces of metric monitoring data.
URI
POST /V1.0/{project_id}/metric-data
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
Definition Project ID. It is used to specify the project that an asset belongs to. You can query the assets of a project by project ID. You can obtain the project ID from the API or console. For details, see Obtaining a Project ID. Constraints N/A Range 1 to 64 characters Default Value N/A |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
[items] |
Yes |
Array of CreateMetricDataRequestBody objects |
Request parameter for adding one or more pieces of custom metric data. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
metric |
Yes |
MetricInfo object |
Definition: Metric data. Constraints: N/A |
|
ttl |
Yes |
Integer |
Definition: Data validity period, in seconds. If the validity period expires, data will be automatically deleted. Constraints: N/A Range: The value is an integer ranging from 1 to 604800. Default Value: N/A |
|
collect_time |
Yes |
Long |
Definition: Time when the data was collected. The value is a UNIX timestamp in milliseconds. Constraints: N/A Range: Since there is a latency between the client and the server, the timestamp when data was inserted must be within the time range [Current time – 3d + 10s, Current time + 10 mins – 10s]. In this way, the data will be inserted to the database without being affected by the latency. Default Value: N/A |
|
value |
Yes |
Double |
Definition: Value of the monitored metric data to be added. Constraints: N/A Range: The value can be an integer or a floating point number. Default Value: N/A |
|
unit |
No |
String |
Definition: Data unit. Constraints: N/A Range: [0,32] Default Value: N/A |
|
type |
No |
String |
Definition: Data type. Constraints: N/A Range: The value can be:
Default Value: N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
namespace |
Yes |
String |
Metric namespace, which must be in the service.item format and contain 3 to 32 characters. service and item each must start with a letter and contain only letters, digits, and underscores (_). Note: This parameter can be empty when alarm_type is set to EVENT.SYS or EVENT.CUSTOM. For example, the ECS namespace is SYS.ECS, and the DDS namespace is SYS.DDS. For the namespace of each service, see Service Namespaces. |
|
metric_name |
Yes |
String |
Definition: Metric ID. For example, metric_name of ECS CPU usage is cpu_util. For details about the namespace of each service, see [Service Namespace] (ces_03_0059.xml). Constraints: None Range: The value must start with a letter and can contain only digits, letters (case-insensitive), underscores (_), and hyphens (-). For example, the ECS metric cpu_util indicates the CPU usage of an ECS. The DDS metric mongo001_command_ps indicates the command execution frequency. The length of the character string is [1,96]. Default Value: None |
|
dimensions |
Yes |
Array of MetricsDimension objects |
Definition: Dimension of a metric. Constraints: A maximum of four dimensions are supported. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
name |
Yes |
String |
Definition: Dimension of a resource. For example, the dimension of an ECS can be instance_id. A maximum of four dimensions are supported. For the metric dimension of each resource, see Service metric dimension. Constraints N/A Range: The value starts with a letter and can contain letters, digits, underscores (_), or hyphens (-). The length is [1,32] characters. Default Value: N/A |
|
value |
Yes |
String |
Definition Resource dimension value, which is an instance ID, for example, 4270ff17-aba3-4138-89fa-820594c39755. Constraints N/A Range 1 to 256 characters Default Value N/A |
Response Parameters
Status code: 201
Created
Status code: 400
|
Parameter |
Type |
Description |
|---|---|---|
|
- |
String |
Request error. |
Status code: 401
|
Parameter |
Type |
Description |
|---|---|---|
|
- |
String |
The authentication information is not provided or is incorrect. |
Status code: 403
|
Parameter |
Type |
Description |
|---|---|---|
|
- |
String |
Access to the requested page is forbidden. |
Status code: 408
|
Parameter |
Type |
Description |
|---|---|---|
|
- |
String |
The request timed out. |
Status code: 429
|
Parameter |
Type |
Description |
|---|---|---|
|
- |
String |
Too many requests. |
Status code: 500
|
Parameter |
Type |
Description |
|---|---|---|
|
- |
String |
Failed to complete the request because of an internal service error. |
Status code: 503
|
Parameter |
Type |
Description |
|---|---|---|
|
- |
String |
The system is currently unavailable. |
Example Requests
[ {
"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" : "%"
} ]
Example Responses
None
Status Codes
|
Status Code |
Description |
|---|---|
|
201 |
Created |
|
400 |
Bad Request |
|
401 |
Unauthorized |
|
403 |
Forbidden |
|
408 |
Request Timeout |
|
429 |
Too Many Requests |
|
500 |
Internal Server Error |
|
503 |
Service Unavailable |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.