All Products
Search
Document Center

Cloud Monitor:Report the monitoring data of custom events by using Alibaba Cloud CLI

Last Updated:Nov 10, 2025

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.

  1. Log on to the RAM console with your 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.

    Important

    Save the AccessKey pair. The AccessKey pair is required when you configure Alibaba Cloud CLI.

  4. 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.

  1. Install Alibaba Cloud CLI.

    For more information, see Install Alibaba Cloud CLI on Windows.

  2. Configure Alibaba Cloud CLI.

    For more information, see Configure a credential of the AccessKey type.

    Important

    The 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

  1. Report the monitoring data of a custom event.

    Sample code:

    aliyun cms PutCustomEvent --EventInfo.1.EventName ErrorEvent  --EventInfo.1.Content helloworld
    Note

    For 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.

  2. View the reported monitoring data of the custom event in the Cloud Monitor console.

    For more information, see View custom events.