All Products
Search
Document Center

CloudMonitor:PutCustomMetric

Last Updated:Mar 25, 2025

Reports monitoring data.

Operation description

Note We recommend that you call the PutHybridMonitorMetricData operation of Hybrid Cloud Monitoring to report monitoring data.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • For mandatory resource types, indicate with a prefix of * .
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
cms:PutCustomMetriccreate
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
MetricListarray<object>Yes

The monitoring data.

objectYes
TypestringYes

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

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

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

cpu_total
TimestringNo

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:

  • A UTC timestamp in the YYYY-MM-DDThh:mm:ssZ format. Example: 20171012T132456.888+0800.
  • A UNIX timestamp of the LONG type. Example: 1508136760000.
1508136760000
GroupIdstringYes

The ID of the application group. Valid values of N: 1 to 21.

Note If the metric does not belong to any application group, enter 0.
12345
ValuesstringYes

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

Note If the Type parameter is set to 0, the keys in this parameter must be set to the specified value. CloudMonitor aggregates raw data in each aggregation period to generate multiple statistical values, such as the maximum value, the count, and the total value.
{"value":10.5}
DimensionsstringYes

The dimensions based on which the resources are queried. Valid values of N: 1 to 21.

Set this parameter to a collection of key-value pairs. Format: {"Key":"Value"}.

The key or value must be 1 to 64 bytes in length. Excessive characters are truncated.

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

Note Dimensions must be formatted as a JSON string in a specified order.
{"sampleName1":"value1","sampleName2":"value2"}
PeriodstringNo

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

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

Response parameters

ParameterTypeDescriptionExample
object
Codestring

The status code.

Note The status code 200 indicates that the request was successful.
200
Messagestring

The error message.

The request has failed due to a temporary failure of the server.
RequestIdstring

The request ID.

05B36C2C-5F6E-48D5-8B41-CE36DD7EE8E0

Examples

Sample success responses

JSONformat

{
  "Code": "200",
  "Message": "The request has failed due to a temporary failure of the server.",
  "RequestId": "05B36C2C-5F6E-48D5-8B41-CE36DD7EE8E0"
}

Error codes

HTTP status codeError codeError message
400%s%s
500InternalError%s

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
No change history