This topic describes how to report the monitoring data of custom events by using Alibaba Cloud Command Line Interface (CLI). In this example, a Resource Access Management (RAM) user is created by using an Alibaba Cloud account, and then the RAM user uses an AccessKey pair to report the monitoring data of custom events.
Step 1: Create a RAM user and grant the permissions to manage Cloud Monitor to the RAM user
After you create a RAM user by using your Alibaba Cloud account, create an AccessKey pair for the RAM user and attach the AliyunCloudMonitorFullAccess policy to the RAM user.
Log on to the RAM console with your 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.
ImportantSave the AccessKey pair. The AccessKey pair is required when you configure Alibaba Cloud CLI.
Attach the AliyunCloudMonitorFullAccess policy to the RAM user.
For more information, see Grant permissions to a RAM user.
Step 2: Install and configure Alibaba Cloud CLI
In this example, Alibaba Cloud CLI is installed and configured on Windows.
Install Alibaba Cloud CLI.
For more information, see Install Alibaba Cloud CLI on Windows.
Configure Alibaba Cloud CLI.
For more information, see Configure a credential of the AccessKey type.
ImportantThe AccessKey ID and AccessKey secret are the AccessKey pair created in Substep 3 of Step 1.
Step 3: Report the monitoring data of a custom event
Report the monitoring data of a custom event.
Sample code:
aliyun cms PutCustomEvent --EventInfo.1.EventName ErrorEvent --EventInfo.1.Content helloworldNoteFor more information about how to set the request parameters for the PutCustomEvent operation, see PutCustomEvent.
Status code 200 is returned, indicating that the monitoring data of the custom event is reported.
{ "Code": "200", "Message": "success", "RequestId": "50958CD5-C81A-5747-9154-4AFC430E3541" }The following table describes the returned error codes.
Error code
Description
400
The request contains a syntax error.
403
The verification failed, the rate reached the throttling threshold, or the required permission was unavailable.
500
An internal server error occurred.
View the reported monitoring data of the custom event in the Cloud Monitor console.
For more information, see View custom events.