You can use Managed Service for Prometheus to monitor Tencent Cloud resources by deploying the open-source QCloud exporter.
Prerequisites
-
You have created a Container Service for Kubernetes (ACK) cluster. For more information, see Create an ACK dedicated cluster (New creation is discontinued).
-
You have connected your Container Service for Kubernetes (ACK) cluster to Managed Service for Prometheus. For more information, see Container Observability.
Background information
The open-source QCloud exporter converts Tencent Cloud Monitor metrics into the Prometheus format. Prometheus scrapes these metrics from the exporter to monitor Tencent Cloud resources.
Tencent Cloud Cloud Monitor (CM) provides unified real-time monitoring and alerts for Tencent Cloud resources such as cloud servers and cloud databases. The QCloud exporter is a Prometheus third-party exporter. The following table lists the supported Tencent Cloud resources.
|
Product |
Namespace |
Supported metrics |
|
TencentDB for MongoDB |
QCE/CMONGO |
|
|
Cloud Database (CDB) |
QCE/CDB |
|
|
TencentDB for Redis (Standard Edition) |
QCE/REDIS |
Metric details are not available. |
|
TencentDB for Redis (Cluster Edition) |
QCE/REDIS_CLUSTER |
Metric details are not available. |
|
TencentDB for Redis (Memory Edition) |
QCE/REDIS_MEM |
|
|
cloud server |
QCE/CVM |
|
|
Cloud Object Storage (COS) |
QCE/COS |
|
|
Content Delivery Network (CDN) |
QCE/CDN |
|
|
Cloud Load Balancer (public network) |
QCE/LB_PUBLIC |
|
|
Cloud Load Balancer (Layer-7) |
QCE/LOADBALANCE |
|
|
NAT Gateway |
QCE/NAT_GATEWAY |
|
|
Direct Connect |
QCE/DC |
|
|
Direct Connect Tunnel |
QCE/DCX |
|
|
cloud disk |
QCE/CBS |
|
|
TencentDB for SQL Server |
QCE/SQLSERVER |
|
|
TencentDB for MariaDB |
QCE/MARIADB |
|
|
Elasticsearch Service |
QCE/CES |
|
|
Cloud Message Queue (CMQ) Queue Service |
QCE/CMQ |
|
|
CMQ Topic Subscription |
QCE/CMQTOPIC |
|
|
TencentDB for PostgreSQL |
QCE/POSTGRES |
|
|
CKafka instance |
QCE/CKAFKA |
|
|
Memcached |
QCE/MEMCACHED |
Metric details are not available. |
|
Lighthouse |
QCE/LIGHTHOUSE |
Metric details are not available. |
|
TDSQL for MySQL |
QCE/TDMYSQL |
|
|
Elastic IP Address (EIP) |
QCE/LB |
Procedure
The following diagram shows the workflow for monitoring Tencent Cloud resources with Managed Service for Prometheus.
Step 1: Deploy the QCloud exporter
-
Build the image.
git clone https://github.com/tencentyun/tencentcloud-exporter.git make build -
Define the product instance configuration.
-
Configure credential information for the cloud API.
-
Configure the products, metrics, and instances to export.
For example, to export all metrics and instances for a cloud server, use the following configuration.
credential: access_key: "access_key" # The SecretId of the cloud API. secret_key: "secret_key" # The SecretKey of the cloud API. region: "ap-nanjing" # The region where the instance is located. rate_limit: 15 # The rate limit for pulling data from Cloud Monitor. The maximum is 20 calls/second or 1,200 calls/minute. For more information, see https://cloud.tencent.com/document/product/248/31014. products: - namespace: QCE/CVM # For metric details, see https://cloud.tencent.com/document/product/248/6843. all_metrics: true # Export all supported metrics. all_instances: true # Export all instances in the region. #only_include_metrics: [] #only_include_instances: [ins-xxxxxxxx] extra_labels: [InstanceId, InstanceName] # Export instance fields as metric labels. #statistics_types: [last] #period_seconds: 60 #metric_name_type: 2NoteFor more information about how to configure the
qcloud.yamlfile, see the tencentcloud-exporter documentation. -
-
Deploy the QCloud exporter.
Build a Docker image with the configuration file and upload it to a repository, such as Docker Hub or Container Registry (ACR).
Log on to the ACK console. In the left navigation pane, click Clusters.
-
On the Clusters page, find the target cluster and click Applications in the Operation column.
-
Create a Deployment.
-
In the left-side navigation pane, choose .
-
On the Stateless page, click Create Resources in YAML.
-
On the Create page, enter the following YAML in the Template 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: TCP
-
-
Create a service.
-
In the left-side navigation pane, choose .
-
On the Service page, click Create Resources in YAML.
-
On the Create page, enter the following YAML in the Template 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-demo
-
Step 2: Configure service discovery
Configure service discovery in Managed Service for Prometheus to scrape metrics from the QCloud exporter.
Ensure that your ACK cluster is connected to Managed Service for Prometheus. For more information, see Prometheus instance for Container Service.
Log on to the Managed Service for Prometheus console.
-
In the navigation pane on the left, click Instances.
-
In the top menu bar, select the region of your ACK cluster, and then click the target instance name.
-
In the left-side navigation pane, click Service Discovery, and then click the Configurations tab.
-
On the Configurations page, click the ServiceMonitor tab, then click Add ServiceMonitor, and in the Add ServiceMonitor dialog box, enter the following content 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-demoThe new service discovery configuration appears on the ServiceMonitor page.

Step 3: Create an alert rule
Create a Prometheus alert rule. For instructions, see Create a Prometheus alert rule.