This document describes how to use APIs to pull the monitoring data of Tencent Cloud services.
Cloud Monitor provides the following two types of APIs for querying metric monitoring data
||Queries the details of basic monitoring metric
||This API is used to query the types of basic monitoring metrics under the corresponding namespace
||Pulls metric monitoring data
||This API is used to get the corresponding monitoring data of a metric in the object dimension
GetMonitorData API supports getting the monitoring data of a certain metric for all instances under an account in batches.
GetMonitorData API can be called 20 times per second (1,200 times/minute) by default. A single request can get the data of up to 10 instances and up to 1,440 data points.
- The retention period of monitoring data varies by monitoring granularity as detailed below:
The monitoring data of 1-minute metrics related to CPU, memory, and network for CVM is retained for 31 days.
Preparing personal key
- Go to Manage API Key.
- If no key has been created, you need to click Create Key to create a key. If you have already created a key, you can click Display after
SecretKey to get the key.
Preparing Tencent Cloud service metric information
This document takes the CVM CPU utilization metric as an example.
- Go to CVM Monitoring Metrics.
- Find the CPU utilization metric to view the CPU utilization metric name, dimension, statistical period, and other related information.
This demo describes how to use the GetMonitorData API to query the CPU utilization of a CVM instance.
- Log in to API Explorer.
- Copy the prepared personal key into the corresponding SecretId and SecretKey text boxes.
- Find Region in the Input Parameters section and select the relevant region.
- Enter the prepared Tencent Cloud service information in the corresponding text boxes in the Input Parameters section.
- Namespace: enter QCE/CVM.
- MetricName: enter the name of the CPU utilization metric, i.e., CPUUsage.
- Dimensions.N-Name: enter the supported dimension name, i.e., InstanceId.
- Dimensions.N-Value: enter the corresponding InstanceId value (CVM instance ID), such as ins—12345678, which can be obtained through the DescribeInstances API of CVM.
- Period: enter a statistical period supported by the metric, such as 300.
- StartTime: enter the query start time in the format of
2020-12-20T19:51:23+08:00 (in the
- EndTime: enter the query end time in the format of
2020-12-20T20:51:23+08:00 (in the
datetime_iso type). EndTime cannot be earlier than StartTime.
- After completing the above information, you can copy the code in the corresponding language on the Code Generation tab to integrate the relevant monitoring data into your self-built monitoring system. You can also use Online Call to send a request to query the monitoring data online.