This topic describes how to report custom events by using Alibaba Cloud Command Line Interface (CLI).

Grant permissions on CloudMonitor to a RAM user

CloudMonitor allows you to use an Alibaba Cloud account or a Resource Access Management (RAM) user to report custom events. If a RAM user needs to use its AccessKey to report custom events, you must grant permissions on CloudMonitor to the RAM user. Perform the following steps:
  1. Log on to the RAM console with an Alibaba Cloud account.
  2. Create a RAM user.

    For more information, see Create a RAM user.

  3. Create an AccessKey pair for the RAM user.

    For more information, see Create an AccessKey pair for a RAM user.

  4. 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 What is Alibaba Cloud CLI?

Report custom events

Call the PutCustomEvent API operation to report custom events. For more information, see PutCustomEvent.

Sample command:
aliyun cms PutCustomEvent --EventInfo.1.EventName ErrorEvent  --EventInfo.1.Content helloworld --EventInfo.1.Time "20171013T170923.456+0800"  --EventInfo.1.GroupId 0
CloudMonitor returns the status code 200, indicating that the event was reported.
{
    "Message": "success",
    "RequestId": "AB4BCB36-A048-4BD7-9530-46802D5F23ED",
    "Code": "200"
}

Error codes

The following table describes the status codes that may be returned when you report custom events by using Alibaba Cloud CLI.
Error code Description
400 The error code returned because the request contains a syntax error.
403 The error code returned because the verification failed, the rate reached the throttling threshold, or the required permission was unavailable.
500 The error code returned because an internal server error occurred.