Reports monitoring data.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes PutCustomMetric

The operation that you want to perform. Set the value to PutCustomMetric.

MetricList.N.Dimensions String Yes {"sampleName1":"value1","sampleName2":"value2"}

The dimensions that specify the resources for which you want to report monitoring data. Valid values of N: 1 to 21.

Set the value to a collection of key-value pairs. A typical key-value pair is instanceId:XXXXXX.

The key and value must be 1 to 64 bytes in length, respectively. Excessive bytes are truncated from the string.

The key and value can contain letters, digits, periods (.), hyphens (-), underscores (_), forward slashes (/), and backslashes (\).

Note Dimensions must be organized in a JSON string and follow the required order.
MetricList.N.GroupId String Yes 12345

The ID of the application group. If the reported monitoring data belongs to no application groups, set the value to 0. Valid values of N: 1 to 21.

MetricList.N.MetricName String Yes cpu_total

The name of the metric. Valid values of N: 1 to 21. For more information, see Appendix 1: Metrics.

MetricList.N.Values String Yes {"value":10.5}

The collection of metric values. Valid values of N: 1 to 21.

Note If the MetricList.N.Type parameter is set to 0, the keys in this parameter must be set to the specified value. Cloud Monitor aggregates raw data in each aggregation period to generate multiple statistical values, such as the maximum value, the count, and the total value.
MetricList.N.Time String No 1508136760000

The timestamp when the metric data is generated. Valid values of N: 1 to 21. The timestamp can be in one of the following formats:

  • The UTC timestamp, in the YYYY-MM-DDThh:mm:ssZ format. Example: 20171012T132456.888+0800.
  • The UNIX timestamp of the LONG type. Example: 1508136760000.
MetricList.N.Type String No 0

The type of the reported data. Valid values of N: 1 to 21. Valid values:

  • 0: reports raw data.
  • 1: reports aggregate data.
Note We recommend that you report aggregate data in both the aggregation periods of 60s and 300s. Otherwise, you cannot query monitoring data in a time span that is more than seven days.
MetricList.N.Period String No 60

The aggregation period. Valid values of N: 1 to 21. Unit: seconds. Value: 60 or 300.

Note If the MetricList.N.Type parameter is set to 1, the MetricList.N.Period parameter is required.

Response parameters

Parameter Type Example Description
RequestId String 05B36C2C-5F6E-48D5-8B41-CE36DD7EE8E0

The ID of the request.

Code String 200

The HTTP status code.

Note The status code 200 indicates that the call was successful.
Message String The Request is not authorization.

The returned message.

Examples

Sample requests

http(s)://[Endpoint]/? Action=PutCustomMetric
&MetricList.1.Dimensions={"sampleName1":"value1","sampleName2":"value2"}
&MetricList.1.GroupId=12345
&MetricList.1.MetricName=cpu_total
&MetricList.1.Values={"value":10.5}
&<Common request parameters>

Sample success responses

XML format

<PutCustomMetric>
          <RequestId>05B36C2C-5F6E-48D5-8B41-CE36DD7EE8E0</RequestId>
          <Code>200</Code>
</PutCustomMetric>

JSON format

{
    "RequestId": "05B36C2C-5F6E-48D5-8B41-CE36DD7EE8E0",
    "Code": "200"
}

Error codes

For a list of error codes, visit the API Error Center.