Querying Monitoring Metrics: Guide for Calling the GetMonitorDat
Last Updated At: 2025-11-17 14:43:28
- API description
| API Name | Version | API Feature |
|---|---|---|
| GetMonitorData | 2017/3/12 | Pulls the monitoring data of cloud product metrics. |
- Input parameters
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| Namespace | Yes | String | Namespace, such as qce/cvm. For detailed namespaces of each cloud product, see the appendix of this document. Example value: qce/cvm. |
| MetricName | Yes | String | Metric name, such as cpu_usage. Only single-metric pulling is supported. For detailed metric descriptions of each cloud product, see the appendix of this document. Example value: cpu_usage. |
| Dimensions | Yes | Array | The dimension group of instance objects, in the form of a collection of key-value pairs. The fields of different instance types are completely different. For example, the field of CVM is [{"unInstanceId": "ins-miltleuc"}]. For the dimensions of each cloud product, see the appendix of this document. A single request supports pulling monitoring data for up to 10 instances in batches. Example value: [{"unInstanceId": "ins-miltleuc"}, {"unInstanceId": "ins-4xny0cbt"}] |
| Period | Yes | Integer | Monitoring statistical period, such as 60, in seconds. The statistical period supported by each metric may not be the same. For the statistical periods supported by each cloud product, see the appendix of this document. The maximum number of data points of a single request is 1,440. Example value: 300. |
| StartTime | Yes | Time | Start time, for example, 2018-09-22T19:51:23+08:00. Example value: 2019-03-24T10:51:23+08:00. |
| EndTime | Yes | Time | End time, such as 2018-09-22T20:51:23+08:00. The current time is used by default. EndTime cannot be earlier than StartTime. Example value: 2019-03-24T20:51:23+08:00. |
- Request domain name
API request domain name: monitor.api3.${domain_main}, such as monitor.api3.3100light2az.fsphere.cn.Note:${domain_main} can be obtained by logging into any Pod, opening /convergecloud/conf/cm/local.json, and searching for the domain_main keyword.

4. Request region
Since monitoring data is reported and stored by region, it is necessary to explicitly specify the region where the instance to be pulled is located when an API is called. The method to obtain region information is as follows:
Log in to any Pod, open /convergecloud/conf/cm/local.json, search for the region_list keyword, and the region_name indicates available regions.
5. Calling frequency limit
Default API request frequency limit: 20 times/second.
6. Output parameters
| Parameter Name | Type | Description |
|---|---|---|
| MetricName | String | Metric name. Example value: cpu_usage. |
| Period | Integer | Monitoring statistical period. Example value: 60. |
| DataPoints[].Dimensions | Json | Instance object dimension group. Example value: {"unInstanceId": "ins-miltleuc"}. |
| DataPoints[].Points | Array | Data point array. |
| StartTime | Time | Start time. Example value: 2019-03-24T10:50:00+08:00. |
| EndTime | Time | End time. Example value: 2019-03-24T20:50:00+08:00. |
| RequestId | String | Unique request ID. It is generated by the server and is returned for each request. (No RequestId is returned if the request is not received by the server due to certain reasons.) RequestId is required for locating an issue. |
- Examples
Pull CPU utilization monitoring data with a 5-minute statistical period for a CVM instance over a period.
Input examplePOST HTTP/1.1 Host: monitor.api3.3100light2az.fsphere.cn Content-Type: application/json Action: GetMonitorData { "Namespace": "qce/cvm", "MetricName": "CPUUsage", "Period": 300, "Dimensions": [ { "unInstanceId": "ins-miltleuc" } ], "StartTime": "2024-03-24T10:51:23+08:00", "EndTime": "2024-03-24T20:51:23+08:00" }
Output example{ "Response": { "StartTime": "2019-03-24 10:50:00", "EndTime": "2019-03-24 20:50:00", "Period": 300, "MetricName": "cpu_usage", "DataPoints": [ { "Dimensions": { "unInstanceId": "ins-miltleuc" }, "Points": [ 2.566, 2.283, 6.316, 2.816, 2.7, 2.35 ] } ], "RequestId": "d96ec542-6547-4af2-91ac-fee85c1b8b85" } }
- SDK code calling
Pull CPU utilization monitoring data with a 5-minute statistical period for a CVM instance over a period.- Golang example
package main
- Golang example
import ( "fmt" "github.com/convergecloud/convergecloud-sdk-go/convergecloud.common" "github.com/convergecloud/convergecloud-sdk-go/convergecloud.common/errors" "github.com/convergecloud/convergecloud-sdk-go/convergecloud.common/profile" monitor "github.com/convergecloud/convergecloud-sdk-go/convergecloud/monitor/v20170312")
func main() { secretId := "AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" secretKey := "eyzi69sGK3SWFeiblb8NKwD9l2yZplNf"
credential := common.NewCredential(secretId, secretKey) cpf := profile.NewClientProfile() cpf.HttpProfile.Scheme = "HTTP" cpf.HttpProfile.ReqTimeout = 10 cpf.HttpProfile.Endpoint = "monitor.api3.3100light2az.fsphere.cn" client, _ := monitor.NewClient(credential, "city1", cpf)
request := monitor.NewGetMonitorDataRequest()
request.Namespace = common.StringPtr("qce/cvm") request.MetricName = common.StringPtr("cpu_usage") request.Period = common.Uint64Ptr(60) request.StartTime = common.StringPtr("2024-10-17T15:10:42+08:00") request.EndTime = common.StringPtr("2024-10-17T16:10:42+08:00")
// Building the Dimensions field dimensions := []string{ "{\"unInstanceId\": \"ins-miltleuc\"}", } request.Dimensions = common.StringPtrs(dimensions) response, err := client.GetMonitorData(request)
if _, ok := err.(*errors.CloudSDKError); ok { fmt.Printf("An API error has returned: %s", err) return } if err != nil { panic(err) } fmt.Printf("%s", response.ToJsonString())}
Lines 13 to 14: secretId and secretKey are calling credentials used for calling authentication, which means that through secretId and secretKey, the called AppID and UIN can be identified. secretId and secretKey are created in the following ways:
Line 20: Endpoint is the calling domain name. For how to obtain it, see 3. Request Domain.
Line 21: "city1" is the region where the monitoring data of cloud product instances is located. For how to obtain it, see 4. Request Region.
- Python example
# -*- coding: utf8 -*-import jsonfrom convergecloud.common import credentialfrom convergecloud.common.exception.cloud_sdk_exception import CloudSDKExceptionfrom convergecloud.monitor.v20170312 import monitor_client, modelsfrom convergecloud.common.profile.client_profile import ClientProfilefrom convergecloud.common.profile.http_profile import HttpProfileimport ssl
ssl._create_default_https_context = ssl._create_unverified_context
try: secret_id = "AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" secret_key = "1qVuzkBH3WgWhX3F7LJyJJyIJ0NP77rM" cred = credential.Credential(secret_id, secret_key)
httpProfile = HttpProfile() httpProfile.endpoint = "monitor.api3.3100light2az.fsphere.cn"
clientProfile = ClientProfile() clientProfile.httpProfile = httpProfile client = monitor_client.MonitorClient(cred, "city1", clientProfile)
req = models.GetMonitorDataRequest() params = { "Namespace": "qce/cvm", "MetricName": "cpu_usage", "Period": 60, "StartTime": "2024-10-17T15:10:42+08:00", "EndTime": "2024-10-17T16:10:42+08:00", "Dimensions": ['''{"unInstanceId": "ins-miltleuc"}'''] } req.from_json_string(json.dumps(params)) resp = client.GetMonitorData(req)
print(resp.to_json_string(indent=2))
except CloudSDKException as err: print(err)
Lines 14 to 15: secretId and secretKey are calling credentials used for calling authentication, which means that through secretId and secretKey, the called AppID and UIN can be identified. secretId and secretKey are created in the following ways:
Line 19: Endpoint is the calling domain name. For how to obtain it, see 3. Request Domain.
Line 23: "city1" is the region where the monitoring data of cloud product instances is located. For how to obtain it, see 4. Request Region.
- Appendix
Namespace Metric Name Time Granularity Dimension Group Dimension Group Example qce/cvm cpu_usage 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" cpu_loadavg 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" CPULoadAvg5m 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" CPULoadAvg15m 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" base_cpu_usage 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" gpu_mem_total 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" GpuMemUsage 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" gpu_mem_used 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" GpuPowDraw 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" GpuPowLimit 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" GpuPowUsage 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" GpuTemp 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" GpuUtil 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" lan_outtraffic 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" lan_intraffic 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" lan_outpkg 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" lan_inpkg 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" tcp_curr_estab 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" mem_used 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" mem_usage 60/300/3600/86400 unInstanceId "unInstanceId":"ins-096makkh" qce/lb_private outtraffic 60/300/3600/86400 vip "vip":"111.111.111.11" intraffic 60/300/3600/86400 vip "vip":"111.111.111.11" outpkg 60/300/3600/86400 vip "vip":"111.111.111.11" inpkg 60/300/3600/86400 vip "vip":"111.111.111.11" connum 60/300/3600/86400 vip "vip":"111.111.111.11" new_conn 60/300/3600/86400 vip "vip":"111.111.111.11"