Anda dapat menggunakan Managed Service for Prometheus untuk memantau sumber daya Tencent Cloud dengan men-deploy QCloud exporter open-source.
Prasyarat
-
Anda telah membuat kluster Container Service for Kubernetes (ACK). Untuk informasi selengkapnya, lihat Buat kluster khusus ACK (Pembuatan baru telah dihentikan).
-
Anda telah menghubungkan kluster Container Service for Kubernetes (ACK) ke Managed Service for Prometheus. Untuk informasi selengkapnya, lihat Container Observability.
Informasi latar belakang
QCloud exporter open-source mengonversi metrik dari Tencent Cloud Monitor ke dalam format Prometheus. Prometheus kemudian mengambil metrik tersebut dari exporter untuk memantau sumber daya Tencent Cloud.
Cloud Monitor (CM) Tencent Cloud menyediakan pemantauan waktu nyata dan peringatan terpadu untuk sumber daya Tencent Cloud seperti cloud server dan cloud database. QCloud exporter merupakan Prometheus third-party exporter. Tabel berikut mencantumkan sumber daya Tencent Cloud yang didukung.
|
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 |
Prosedur
Diagram berikut menunjukkan alur kerja untuk memantau sumber daya Tencent Cloud dengan Managed Service for Prometheus.
Langkah 1: Deploy QCloud exporter
-
Bangun image.
git clone https://github.com/tencentyun/tencentcloud-exporter.git make build -
Tentukan konfigurasi instans produk.
-
Konfigurasikan informasi kredensial untuk cloud API.
-
Konfigurasikan produk, metrik, dan instans yang akan diekspor.
Sebagai contoh, untuk mengekspor semua metrik dan instans untuk cloud server, gunakan konfigurasi berikut.
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: 2CatatanUntuk informasi selengkapnya tentang cara mengonfigurasi file
qcloud.yaml, lihat dokumentasi tencentcloud-exporter. -
-
Deploy QCloud exporter.
Bangun image Docker dengan file konfigurasi dan unggah ke repositori, seperti Docker Hub atau Container Registry (ACR).
Masuk ke ACK console. Di panel navigasi kiri, klik Clusters.
-
Pada halaman Clusters, temukan kluster target dan klik Applications di kolom Operation.
-
Buat Deployment.
-
Di panel navigasi sebelah kiri, pilih .
-
Pada halaman Stateless, klik Create Resources in YAML.
-
Pada halaman Create , masukkan YAML berikut di editor Template dan klik 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
-
-
Buat layanan.
-
Di panel navigasi sebelah kiri, pilih .
-
Pada halaman Service, klik Create Resources in YAML.
-
Pada halaman Create , masukkan YAML berikut di editor Template dan klik 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
-
Langkah 2: Konfigurasikan penemuan layanan
Konfigurasikan penemuan layanan di Managed Service for Prometheus untuk mengambil metrik dari QCloud exporter.
Pastikan kluster ACK Anda telah terhubung ke Managed Service for Prometheus. Untuk informasi selengkapnya, lihat Prometheus instance for Container Service.
Masuk ke Managed Service for Prometheus console.
-
Di panel navigasi kiri, klik Instances.
-
Di bilah menu atas, pilih wilayah kluster ACK Anda, lalu klik nama instans target.
-
Di panel navigasi sebelah kiri, klik Service Discovery, lalu klik tab Configurations.
-
Pada halaman Configurations, klik tab ServiceMonitor, lalu klik Add ServiceMonitor, dan pada kotak dialog Add ServiceMonitor, masukkan konten berikut dan klik 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-demoKonfigurasi penemuan layanan baru muncul di halaman ServiceMonitor.

Langkah 3: Buat aturan peringatan
Buat aturan peringatan Prometheus. Untuk petunjuknya, lihat Create a Prometheus alert rule.