Deploy the QCloud exporter on a Container Service for Kubernetes (ACK) cluster to collect Tencent Cloud metrics in Managed Service for Prometheus. This gives you cross-cloud visibility from a single monitoring platform.
How it works
The QCloud exporter is a third-party Prometheus exporter that queries the Tencent Cloud CM API and exposes metrics at a /metrics endpoint. After you deploy the exporter as a pod in your ACK cluster, a ServiceMonitor tells Managed Service for Prometheus to scrape that endpoint at a regular interval.
The overall workflow:
Build and deploy the QCloud exporter in your ACK cluster.
Create a ServiceMonitor so that Managed Service for Prometheus discovers and scrapes the exporter.
Configure alert rules on the collected metrics.
Supported Tencent Cloud services
The QCloud exporter supports the following Tencent Cloud services. Each row links to the corresponding CM metric reference.
| Service | Namespace | Metrics |
|---|---|---|
| TencentDB for MongoDB | QCE/CMONGO | Metric details |
| Cloud Database | QCE/CDB | Metric details |
| TencentDB for Redis (standard architecture) | QCE/REDIS | N/A |
| TencentDB for Redis (cluster architecture) | QCE/REDIS_CLUSTER | N/A |
| TencentDB for Redis (Memory Edition) | QCE/REDIS_MEM | Metric details |
| Cloud Virtual Machine (CVM) | QCE/CVM | Metric details |
| Cloud Object Storage (COS) | QCE/COS | Metric details |
| Content Delivery Network (CDN) | QCE/CDN | Metric details |
| Cloud Load Balancer (Internet) | QCE/LB_PUBLIC | Metric details |
| Cloud Load Balancer (Layer 7) | QCE/LOADBALANCE | Metric details |
| NAT Gateway | QCE/NAT_GATEWAY | Metric details |
| Direct Connect (connection) | QCE/DC | Metric details |
| Direct Connect (dedicated tunnel) | QCE/DCX | Metric details |
| Cloud Block Storage (CBS) | QCE/CBS | Metric details |
| TencentDB for SQL Server | QCE/SQLSERVER | Metric details |
| TencentDB for MariaDB | QCE/MARIADB | Metric details |
| Elasticsearch Service (CES) | QCE/CES | Metric details |
| Cloud Message Queue (queue service) | QCE/CMQ | Metric details |
| Cloud Message Queue (topic subscription) | QCE/CMQTOPIC | Metric details |
| TencentDB for PostgreSQL | QCE/POSTGRES | Metric details |
| CKafka | QCE/CKAFKA | Metric details |
| Memcached | QCE/MEMCACHED | N/A |
| Lighthouse | QCE/LIGHTHOUSE | N/A |
| TDSQL for MySQL | QCE/TDMYSQL | Metric details |
| Elastic IP | QCE/LB | Metric details |
Prerequisites
Before you begin, make sure that you have:
An ACK cluster. For more information, see Create an ACK dedicated cluster
The ACK cluster connected to Managed Service for Prometheus. For more information, see Monitor an ACK cluster
Step 1: Deploy the QCloud exporter
Build the exporter image
Clone the repository and build the binary:
git clone https://github.com/tencentyun/tencentcloud-exporter.git
make buildConfigure the exporter
Create a configuration file (for example, qcloud.yaml) that specifies your Tencent Cloud credentials and the services to monitor.
The following example exports all CVM metrics for every instance in the ap-nanjing region:
credential:
access_key: "access_key" # The SecretId of TencentCloud API
secret_key: "secret_key" # The SecretKey of TencentCloud API
region: "ap-nanjing" # The region where the instances reside
rate_limit: 15 # The maximum number of API calls that CM can make per second to pull data. Example: 20. For more information, see https://cloud.tencent.com/document/product/248/31014
products:
- namespace: QCE/CVM # CVM metrics. See https://cloud.tencent.com/document/product/248/6843
all_metrics: true # Export all supported metrics
all_instances: true # Export metrics from every instance in the specified region
extra_labels: [InstanceId, InstanceName]
# Optional filters - uncomment and edit as needed:
# only_include_metrics: []
# only_include_instances: [ins-xxxxxxxx]
# statistics_types: [last]
# period_seconds: 60
# metric_name_type: 2For the full list of configuration options, see the tencentcloud-exporter README.
Create a Deployment
Package the exporter and its configuration file into a Docker image, then push the image to a container registry such as DockerHub or Container Registry.
Deploy the exporter to your ACK cluster:
Log on to the ACK console. In the left-side navigation pane, click Clusters.
On the Clusters page, find your cluster and click Applications in the Actions column.
In the left-side navigation pane, choose .
On the Deployments page, click Create from YAML.
On the Create page, enter the following YAML in the Template code editor and click Create:
apiVersion: apps/v1
kind: Deployment
metadata:
generation: 5
labels:
app: qcloud-exporter-demo
name: qcloud-exporter-demo
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: qcloud-exporter-demo
template:
metadata:
labels:
app: qcloud-exporter-demo
spec:
containers:
- args:
- '--config.file=/usr/local/etc/qcloud-cvm-product.yml'
image: 'registry.cn-hangzhou.aliyuncs.com/fuling/qcloud-exporter:v0.1'
imagePullPolicy: Always
name: qcloud-exporter
ports:
- containerPort: 9123
name: web-normal
protocol: TCPCreate a Service
Expose the exporter so that Prometheus can scrape it:
In the left-side navigation pane, choose .
On the Services page, click Create Resources in YAML.
On the Create page, enter the following YAML in the Template code editor and click Create:
apiVersion: v1
kind: Service
metadata:
labels:
app: qcloud-exporter-demo
name: qcloud-exporter-demo-svc
namespace: default
spec:
ports:
- name: qcloud-exporter-metrics
port: 9123
protocol: TCP
targetPort: 9123
selector:
app: qcloud-exporter-demoStep 2: Add a service discovery configuration
Configure a ServiceMonitor so that Managed Service for Prometheus discovers and scrapes the QCloud exporter.
The ACK cluster must already be connected to Managed Service for Prometheus. For more information, see .
Log on to the ARMS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region where the ACK cluster resides, and click the name of the cluster.
In the left-side navigation pane, click Service Discovery. Then, click the Configure tab.
On the Configure tab, click the ServiceMonitor tab, and then click Add ServiceMonitor.
In the Add ServiceMonitor dialog box, enter the following YAML and click OK:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: qcloud-exporter-sm
namespace: default
spec:
endpoints:
- interval: 60s
path: /metrics
port: qcloud-exporter-metrics
scrapeTimeout: 60s
namespaceSelector:
any: true
selector:
matchLabels:
app: qcloud-exporter-demoAfter you save the configuration, the new ServiceMonitor appears on the ServiceMonitor tab.

Step 3: Create an alert rule
After metrics are collected, set up alerts based on them. For instructions, see Create an alert rule for a Prometheus instance.