tencent cloud

TencentCloud Managed Service for Prometheus

Product Introduction
Overview
Strengths
Use Cases
Concepts
Use Limits
Features
Service Regions
Purchase Guide
Billing Overview
Pay-as-You-Go (Postpaid)
Free Trial Introduction
Managed Collector Billing Introduction
Archive Storage Billing Introduction
Purchase Methods
Payment Overdue
Getting Started
Integration Guide
Scrape Configuration Description
Custom Monitoring
EMR Integration
Java Application Integration
Go Application Integration
Exporter Integration
Nacos Integration
Common Exporter
Health Check
Instructions for Installing Components in the TKE Cluster
Cloud Monitoring
Non-Tencent Cloud Host Monitoring
Read Cloud-Hosted Prometheus Instance Data via Remote Read
Agent Self-Service Access
Pushgateway Integration
Security Group Open Description
Operation Guide
Instance
TKE
Integration Center
Data Multi-Write
Recording Rule
Instance Diagnosis
Archive Storage
Alerting Rule
Tag
Access Control
Grafana
API Guide
TKE Metrics
Resource Usage and Billing Overview
Practical Tutorial
Migration from Self-Built Prometheus
Custom Integration with CVM
TKE Monitoring
Enabling Public Network Access for TKE Serverless Cluster
Connecting TMP to Local Grafana
Enabling Public Network Access for Prometheus Instances
Configuring a Public Network Address for a Prometheus Instance
Terraform
Terraform Overview
Managing Prometheus Instances Using Terraform
Managing the Integration Center of Prometheus Instances Using Terraform
Collecting Container Monitoring Data Using Terraform
Configuring Alarm Policies Using Terraform
FAQs
Basic Questions
Integration with TKE Cluster
Product Consulting
Use and Technology
Cloud Monitor FAQs
Service Level Agreement
TMP Policy
Privacy Policy
Data Processing And Security Agreement

Custom Integration with CVM

PDF
Focus Mode
Font Size
Last updated: 2025-08-29 17:36:06
This document describes how to integrate CVM with TMP.

Purchasing a TMP Instance

Note:
The purchased TMP instance must be in the same VPC as the monitored CVM instance for network connectivity.
1. Log in to the TMP console and click Create to purchase a TMP instance.


2. On the purchase page, select the target instance specification and network. Make sure that the TMP and CVM instances have the same VPC IP range so that data can be collected. Select the instance specification based on your reported data volume.

3. Click Buy Now and make the payment.

Integrating CVM Basic Metrics

1. Download and install Node Exporter.
Download and install Node Exporter (used to collect basic metric data) in the target CVM instance. Click here or run the following command for download:
wget https://rig-intl-1258344699.cos.ap-singapore.myqcloud.com/prometheus-agent/node_exporter -O node_exporter
The file directory is as follows:


2. Run Node Exporter to collect basic monitoring data.
2.1 Go to the target folder and run Node Exporter.
cd node_exporter-1.3.1.linux-amd64
./node_exporter
If the following result is displayed, basic monitoring data has been collected successfully.


2.2 Run the following command to expose the basic monitoring data to port 9100:
curl 127.0.0.1:9100/metrics
You can see the following metric monitoring data that is exposed after the command is executed.


3. Add a scrape task. Log in to the TMP console, select Data Collection > Integration Center > CVM Scrape Job, and configure the information in Task Configuration as prompted. Below is a sample configuration of a scrape task:
job_name: example-job-name
metrics_path: /metrics
cvm_sd_configs:
- region: ap-guangzhou
ports:
- 9100
filters:
- name: tag:Sample tag key
values:
- Sample tag value
relabel_configs:
- source_labels: [__meta_cvm_instance_state]
regex: RUNNING
action: keep
- regex: __meta_cvm_tag_(.*)
replacement: $1
action: labelmap
- source_labels: [__meta_cvm_region]
target_label: region
action: replace
4. Check whether data is reported successfully.
Log in to the TMP console and click the Grafana icon to enter Grafana. Search for {job="cvm_node_exporter"} in Explore to see whether there is data, and if so, data is reported successfully.


5. Configure the dashboard page: Every product has some existing JSON files that can be directly imported into the dashboard.
5.1 Download a dashboard file: Go to the Dashboard page, search for node_exporter, and select the latest dashboard for download.



5.2 Import a JSON file into the dashboard: Log in to the TMP console, select Basic Info > Grafana Address to enter Grafana. In the Grafana console, select Create > Import and upload the dashboard file in Upload JSON file.


The effect after configuring is as follows:




Integrating CVM Metrics at the Business Layer

Prometheus provides four metric types for different monitoring scenarios: Counter, Gauge, Histogram, and Summary. The Prometheus community provides SDKs for multiple programing languages, which are basically similar in usage and mainly differ in the syntax. The following uses Go as an example to describe how to report custom monitoring metrics. For detailed directions of other metric types, see Custom Monitoring.

Counter

A metric in Counter type increases monotonically and will be reset after service restart. You can use counters to monitor the numbers of requests, exceptions, user logins, orders, etc.
1. You can use a counter to monitor the number of orders as follows:
package order

import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)

// Define the counter object to be monitored
var (
opsProcessed = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "order_service_processed_orders_total",
Help: "The total number of processed orders",
}, []string{"status"}) // Processing status
)

// Process the order
func makeOrder() {
opsProcessed.WithLabelValues("success").Inc() // Success
// opsProcessed.WithLabelValues("fail").Inc() // Failure

// Order placement business logic
}
For example, you can use the rate() function to get the order increase rate:
rate(order_service_processed_orders_total[5m])
2. Expose Prometheus metrics:
Use promhttp.Handler() to expose the metric tracking data to the HTTP service.
package main

import (
"net/http"

"github.com/prometheus/client_golang/prometheus/promhttp"
)

func main() {
// Business code

// Expose Prometheus metrics in the HTTP service
http.Handle("/metrics", promhttp.Handler())

// Business code
}

3. Collect data:
After the tracking of custom metrics for your business is completed and the application is released, you can use Prometheus to collect the monitoring metric data. After the collection is completed, wait a few minutes and then you can view the business metric monitoring data in Grafana integrated in TMP.

img



Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback