Custom monitoring features provide you with interfaces for reporting monitoring data, it is convenient for you to report the time-series data collected by yourself to cloud monitoring, and configure alarm rules to receive alarm notifications.

CloudMonitor supports data reporting using open APIs, Java SDK, and AliCloudCLI.


  • A single cloud account QPS is limited to 100.
  • Report up to 100 data in a single time, and the body is up to 256kb.
  • The metricname field only supports letters, numbers, and underscores. You need to start with a letter, and the non-letter starts with an upper case of "", the illegal character is replaced with "_".
  • The dimensions field does not support "=", "&", "," ",". illegal characters are replaced with "_".
  • Key-value for metricname and dimensions The maximum is 64 bytes, and more than 64 bytes are truncated.
  • For other restrictions, please pay attention to the billing method.

Report data using open APIs

  • Request Parameters
    Name Type Required Description
    groupId long Yes ID of the apply grouping
    metricName string Yes. Monitor item name, support letter, number, connector '_-. /\ ", The other characters are illegal, with a maximum length of 64 bytes, intercept the first 64 bytes when more than 64 bytes
    dimensions object Yes. The dimension map, key-value are all strings, Support letter, number, connector "_-. /\ ", The maximum number of key value pairs is 10, the maximum length of key is 64 bytes, value is a maximum length of 64 bytes, with the first 64 bytes taken when the length exceeds 64 bytes
    time string Yes. Indicator occurrence time, support for "yyyymmdd't 'hmmmss. sssz "and long-type timestamps in 2 ways, such "20171012t132456. 888 + 0800" or "1508136760000"
    type int Yes. The type of the reported value, 0 is the original value, and 1 is the aggregate data. Recommended 60 s, 300 s when reporting aggregate data The data for the cycle is reported, otherwise the monitoring data that is longer than 7 days old is not available for normal query.
    Period string No The aggregation cycle, in seconds. Required to pass this field if type = 1, value 60, 300
    values object Yes Indicator value collection, when type = 0, key can only be "value ", the original values are reported, and cloud monitoring aggregates the original values to multiple values by period, such as maximum, Count, sum, etc.

    When the raw data is reported through the interface, cloud monitoring calculates the results for 1 minute and 5 minutes according to the following statistics:

    • Average: Average
    • Maximum: Maximum
    • Minimum: Minimum
    • Sum: Sum
    • SampleCount: Count
    • SumPerSecond: count the number of seconds for the sum/corresponding period, or you can use the sliding average calculation
    • CountPerSecond: the number of seconds for the count/corresponding period, or you can use the sliding average calculation
    • Lastvalue: The last sample value of the cycle, similar to gauge
    • Pt10: percentile 0.1, more than 10% all sampling data for this cycle
    • P20: percentile 0.2, more than 20% all sampling data for this cycle
    • P30: percentile 0.3, more than 30% all sampling data for this cycle
    • P40: percentile 0.4, more than 40% all sampling data for this cycle
    • P50: percentile 0.5, greater than 50% all sampling data for this cycle, median
    • P60: percentile 0.6, more than 60% all sampling data for this cycle
    • P70: percentile 0.7, more than 70% all sampling data for this cycle
    • P75: percentile 0.75, more than 75% all sampling data for this cycle
    • P80: percentile 0.8, more than 80% all sampling data for this cycle
    • P90: percentile 0.9, more than 90% all sampling data for this cycle
    • P95: percentile 0.95, more than 95% all sampling data for this cycle
    • P98: percentile 0.98, more than 98% all sampling data for this cycle
    • P99: percentile 0.99, more than 99% all sampling data for this cycle
  • Response Element

    The system returns the HTTP status code 200.

  • Example
    • Request example
      POST /metric/custom/upload HTTP/1.1 
      Date:Mon, 23 Oct 2017 06:51:11 GMT
    • Response example
         "msg": "// return MSG is empty when reporting normally

Sample code

  • Reporting raw data
    Cmsclientinit. groupid = 101l; // set common application group ID
            CMSClient cmsClient = new CMSClient(endpoint, accKey, secret);//initializeclient
            CustomMetricUploadRequest request = CustomMetricUploadRequest.builder()
                            . setMetricName ("testmetric") // Indicator Name
                            . Setgroupid (102l) // set customized grouping ID
                            . Settime (new date ())
                            .setType(CustomMetric.TYPE_VALUE)//type is default value,
                            .appendValue(MetricAttribute.VALUE, 1f)//key value can only be default,key
                            .appendDimension("key", "value")//add dimension
                            .appendDimension("ip", "")//add dimension
            CustomMetricUploadResponse response = cmsClient.putCustomMetric(request);//report
  • Automatic multi-cycle aggregation escalation

    The SDK supports the ability to post data after aggregation locally, the aggregation cycle is 1 minute, 5 minutes.

    Data types Description The value of the aggregate Memory consumption does not include name, dimension, single time series, single aggregation cycle)
    value General Value Type 除了LastValue外的所有属性 About 4 K
    gauge 采样值 Lastvalue 4 bytes
    meter Sum and Rate Sum,SumPerSecond 50 bytes
    Counter Count SampleCount 10 bytes
    Timer Calculation time SampleCount、CountPerSecond、 Average、Maximum、Minimum、PXX(P10-P99) About 4 K
    Histogram Distribution SampleCount、Average、Maximum、Minimum、PXX(P10-P99) About 4 K
            Cmsclientinit. groupId = 0L;
            CMSClient cmsClient = new CMSClient(accKey, secret, endpoint);//create client
            CMSMetricRegistryBuilder builder = new CMSMetricRegistryBuilder();
            final MetricRegistry registry =;//registry contains 2 aggregation cycles
            //or final MetricRegistry registry = _ 60 s); // create only 1 minute of aggregation cycle
    // Use value
    ValueWrapper value = registry.value("value"));
    // Use meter
    MeterWrapper meter = registry.meter("meter"));
    // use counter
    CounterWrapper counter = registry.counter("counter"));;
    // Use Timer
    TimerWrapper timer = registry.timer("timer"));
    timer.update(30, TimeUnit.MILLISECONDS);
    //use histogram
    HistogramWrapper histogram = registry.histogram("histogram"));
    // Use Gauge
    final List list = new ArrayList();
    registry.gauge("gauge"), new Gauge() {
                            @ Override
                            public Number getValue() {
                                return list.size();

Command Line (CLI) method to report data

With an Ali cloud account, and generate Sub-Account AK with cloud monitoring privileges (with Sub-Account Security better ).
  • Create a subaccount.

  • Generate an accesskeyid for the sub-account.

  • Authorize cloud monitoring permissions for sub-accounts.


  1. Installing the aliyuncli Tool
    System Requirements: Linux, Unix or Mac OS. Environmental requirements: Python 2. 7. X is installed.
    1. Installing Python
      • Skip this step if your device has a version of Python 2. 7. x installed.
      • If your device does not have a version of Python 2..x installed, execute the following command in the command line window, install Python. Note that make sure that your device is installed wget.
        wget (or download it in another way and put it on a path)
        tar -zxvf Python-2.7.8.tgz
        cd Python-2.7.8
        sudo make install
    2. Install pip
      • Skip this step if your device has pip installed.
      • If your device does not have pip installed, install the following command in the command line window: pip.
        curl "" -o ""
        sudo python
      • The system displays similar information, indicating that the installation was successful.
        Successfully installed pip-7.1.2 setuptools-18.7 wheel-0.26.0
    3. Install command line tools

      If the pip version is too low on the system, it will cause errors in the CLI installation. The user can use the following command to first pair the pip After the software is upgraded, the relevant operation will be performed. Use pip 7.x or later. If you are already in the latest version of pip, skip this step.

      1. Upgrade by executing the following command in the command line window pip.
        sudo pip install -U pip

        The system displays similar information, indicating that the upgrade was successful.

        Successfully uninstalled pip-7.1.2
        Successfully installed pip-8.1.2
      1. Install the Ali cloud command line tool by performing the following commands.
        sudo pip install aliyuncli

        The system displays similar information, indicating that the installation was successful.

        Successfully installed aliyuncli-2.1.2 colorama-0.3.3 jmespath-0.7.1
    4. Configure command-line tools
      ~ sudo aliyuncli configure
      Aliyun Access Key ID [*******************a]: youraccesskeyid
      Aliyun Access Key Secret [*******************b]: youraccesskeysecret
      Default Region Id [cn-hangzhou]: cn-hangzhou
      Default output format [json]: json
  2. Installing CmsSDK
    • Windows is installed as follows.
      cd C:\Python27\Scripts
      pip install aliyun-python-sdk-cms
    • To update the SDK, run the following command:
      pip install --upgrade aliyun-python-sdk-cms
    • Linux The installation method is as follows.
      sudo pip install aliyun-python-sdk-cms
    • To update the SDK, run the following command:
      sudo pip install —upgrade aliyun-python-sdk-cms
  3. Reporting Monitoring Data

    Use the PutEvent interface.

    • Windows reporting example
      aliyuncli.exe cms PutEvent --EventInfo "[{'content':'helloworld','time':'20171013T170923.456+0800','name':'ErrorEvent','groupId':'27147'}]"
    • Linux Reporting example
      aliyuncli cms PutEvent --EventInfo "[{'content':'helloworld','time':'20171023T180923.456+0800','name':'ErrorEvent','groupId':'27147'}]"
    • Returns a 200 status code after the report is successful.

Error Code

Error code Meaning
200 Normal
400 Syntax Error in client request
403 Calibration FAILED, speed limit, no authorization
500 Server internal error

Sub-account authorization instructions

Subaccount authorization description When the AccessKey of a subaccount is used to report an event, the subaccount must be authorized to manage CloudMonitor. The "cannot upload event" prompt when reporting data if the sub-account is not authorized for cloud monitoring administration, Please use ramto auth ".

  1. Logon to thelRAM console .
  2. Enter the user management menu .
  3. Click authorize next to the sub-account that is used to report data.

  4. On the authorization page, select Manage CloudMonitor, and click OKto save the authorization.