Add Statistics Type

Last updated: 2019-11-29 19:17:45

PDF

1. API Description

This API (CreateMetricStatisticsType) is used to add statistical types for a specified dimension under a metric. A metric may have multiple statistical types.
A metric must have a statistical type, so the analysis result of the reported data can be queried.
You can skip this API if you have entered the information of statistical types when you Create Metric or Create Metric Aggregation.

Domain name: monitor.api.qcloud.com

2. Input Parameters

The following request parameter list only provides API request parameters. Common request parameters are also needed when the API is called. The Action field for this API is CreateMetricStatisticsType.

Parameter Name Required Type Description
namespace Yes String Add the statistical types for the metrics under the namespace. This can be queried by calling the API Query Namespace (DescribeNamespace)
metricName Yes String Add statistical types for the metric. This can be queried by calling the API Query Metric (DescribeMetric)
dimensionNames.n Yes Array Group of all the dimensions or group of aggregated dimensions under the metric. This can be queried by calling the API Query Metric (DescribeMetric)
statisticsType.m.period Yes Int Statistical period (in sec). Currently, you must enter 300 seconds, and other values are not supported
statisticsType.m.statistics Yes String Statistical type, including max, min, last, sum, avg, etc.

The subscript n in dimensionNames.n is the subscript of the dimension under the metric.
You can enter the original dimensions of the metric (i.e. all the dimensions under the metric) or aggregated dimensions under the metric

statisticsType.m.statistics and statisticsType.m.period always come in pairs. You can add multiple groups of statistical types for the dimension of the metric.
The subscript m is the digit subscript of different statistical types
For example: statisticsType.0.statistics=max statisticsType.0.period=300
statisticsType.1.statistics=min statisticsType.1.period=300
This means to take the maximum and minimum values of the reported data within the statistical period (5 minutes).

3. Output Parameters

Parameter Name Type Description
code Int Error code, 0: Successful; other values: Failed. For more information, please see Error Codes
message String Error message

4. Error Codes

Error Code Error Description Error Message
-503 Incorrect request parameter InvalidParameter
-505 Parameter is missing InvalidParameter.MissingParameter
-507 Limit has been exceeded OperationDenied.ExceedLimit
-509 Incorrect dimension group InvalidParameter.DimensionGroupError
-513 DB operation failed InternalError.DBoperationFail

5. Example

Input

https://monitor.api.qcloud.com/v2/index.php?
&<Common request parameters>
&namespace=cvm
&metricName=diskusage
&dimensionNames.0=ip
&dimensionNames.1=diskname
&statisticsType.0.period=300
&statisticsType.0.statistics=avg

Output

{
  'code': 0,
  'message': ''
}