This topic describes how to report monitoring data by using Alibaba Cloud Command Line Interface (CLI).
Grant permissions on Cloud Monitor to a RAM user
- Log on to the RAM console with an Alibaba Cloud account.
- Create a RAM user.
For more information, see Create a RAM user.
- Create an AccessKey pair for the RAM user.
For more information, see Create an AccessKey pair for a RAM user.
- Attach the AliyunCloudMonitorFullAccess policy to the RAM user.
For more information, see Grant permissions to a RAM user.
Install and configure Alibaba Cloud CLI
For more information, see Install Alibaba Cloud CLI in Windows or Install Alibaba Cloud CLI in Linux.
Report monitoring data
Call the PutCustomMetric API operation to report monitoring data. For more information, see PutCustomMetric.
Sample command:
aliyun cms PutCustomMetric --MetricList.1.MetricName cpu_total --MetricList.1.Dimensions '{"sampleName1":"value1","sampleName2":"value2"}' --MetricList.1.Time 1555390981421 --MetricList.1.Type 0 --MetricList.1.Period 60 --MetricList.1.Values '{"value":10.5}' --MetricList.1.GroupId "0"
Cloud Monitor returns the status code 200, indicating that the monitoring data is reported.
{
"Message": "success",
"RequestId": "F69F5623-DDD6-42AE-AE59-87A2B841620B",
"Code": "200"
}
Status codes
Status code | Description |
---|---|
200 | The status code returned when the monitoring data is reported. |
206 |
|
400 | The error code returned because the request contains a syntax error. |
403 | The error code returned because the verification fails, the rate reaches the throttling threshold, or the required permission is unavailable. |
500 | The error code returned because an internal server error occurred. |