Create Index

Last updated: 2017-07-25 11:21:08

1. API Description

This API (CreateMetric) is used to create a metric under a namespace for data analysis.
For more information about the number of metrics and dimensions, please see Product Limitation page
When you use this API to create a metric, you can also add the statistical type under the metric. Add statistical type when you enter statisticsType.m.period and statisticsType.m.statistics.

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. For more information, please see Common Request Parameters page. The Action field for this API is CreateMetric.

Parameter Name Required Type Description
namespace Yes String Namespace, which can be queried by calling the API Query Namespace (DescribeNamespace)
metricName Yes String Metric name, which is comprised of letters, numbers and underscores
metricCname Yes String Chinese name of the metric
dimensionNames.n Yes Array Statistical dimension name of the metric
unit No String The unit used when user reports data. Default is empty string
statisticsType.m.period No Int Statistical period. The time interval for data collection. Currently, default is 300 seconds, which cannot be modified
statisticsType.m.statistics No String Analyze the data set within a specified statistical period. Available analytical methods are: max (to take the maximum value in the data set), min (to take the minimum value in the data set), sum (to take the sum of all data in the data set), avg (to take the average value of all data in the data set), last (to take the last value in the data set)

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
-514 Resource already exists OperationDenied.SourceAlreadyExists

5. Example

Input

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

Output

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