tencent cloud

Tencent Cloud Observability Platform

Release Notes and Announcements
Release Notes
Product Introduction
Overview
Strengths
Basic Features
Basic Concepts
Use Cases
Use Limits
Purchase Guide
Tencent Cloud Product Monitoring
Application Performance Management
Mobile App Performance Monitoring
Real User Monitoring
Cloud Automated Testing
Prometheus Monitoring
Grafana
EventBridge
PTS
Quick Start
Monitoring Overview
Instance Group
Tencent Cloud Product Monitoring
Application Performance Management
Real User Monitoring
Cloud Automated Testing
Performance Testing Service
Prometheus Getting Started
Grafana
Dashboard Creation
EventBridge
Alarm Service
Cloud Product Monitoring
Tencent Cloud Service Metrics
Operation Guide
CVM Agents
Cloud Product Monitoring Integration with Grafana
Troubleshooting
Practical Tutorial
Application Performance Management
Product Introduction
Access Guide
Operation Guide
Practical Tutorial
Parameter Information
FAQs
Mobile App Performance Monitoring
Overview
Operation Guide
Access Guide
Practical Tutorial
Tencent Cloud Real User Monitoring
Product Introduction
Operation Guide
Connection Guide
FAQs
Cloud Automated Testing
Product Introduction
Operation Guide
FAQs
Performance Testing Service
Overview
Operation Guide
Practice Tutorial
JavaScript API List
FAQs
Prometheus Monitoring
Product Introduction
Access Guide
Operation Guide
Practical Tutorial
Terraform
FAQs
Grafana
Product Introduction
Operation Guide
Guide on Grafana Common Features
FAQs
Dashboard
Overview
Operation Guide
Alarm Management
Console Operation Guide
Troubleshooting
FAQs
EventBridge
Product Introduction
Operation Guide
Practical Tutorial
FAQs
Report Management
FAQs
General
Alarm Service
Concepts
Monitoring Charts
CVM Agents
Dynamic Alarm Threshold
CM Connection to Grafana
Documentation Guide
Related Agreements
Application Performance Management Service Level Agreement
APM Privacy Policy
APM Data Processing And Security Agreement
RUM Service Level Agreement
Mobile Performance Monitoring Service Level Agreement
Cloud Automated Testing Service Level Agreement
Prometheus Service Level Agreement
TCMG Service Level Agreements
PTS Service Level Agreement
PTS Use Limits
Cloud Monitor Service Level Agreement
API Documentation
History
Introduction
API Category
Making API Requests
Monitoring Data Query APIs
Alarm APIs
Legacy Alert APIs
Notification Template APIs
TMP APIs
Grafana Service APIs
Event Center APIs
TencentCloud Managed Service for Prometheus APIs
Monitoring APIs
Data Types
Error Codes
Glossary
문서Tencent Cloud Observability PlatformPrometheus MonitoringTerraformManaging the Integration Center of Prometheus Instances Using Terraform

Managing the Integration Center of Prometheus Instances Using Terraform

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2023-12-29 16:09:44

Prerequisites

Installing Terraform

For detailed instructions on installing Terraform, see Installing Terraform.
Note:
The installed version of Terraform must not be below v1.6.3. You can verify the version of Terraform installed by using the command terraform --version.

Configuring Tencent Cloud Account Information

Before using Terraform for the first time, go to API Key to apply for a SecretID and SecretKey of the security credentials. If you already have valid credentials, skip this step.
1. Log in to the CAM Console and choose Access Key > API Keys from the left sidebar.
2. On the API Keys page, click Create Key to create a SecretId/SecretKey pair.

There are two methods for configuring Tencent Cloud account information:

Authentication by Static Credentials
Create a provider.tf file in the user directory with the following content. Replace my-secret-id and my-secret-key with your SecretId and SecretKey, respectively.
provider "tencentcloud" {
secret_id = "my-secret-id"
secret_key = "my-secret-key"
}
Authentication by Environment Variables
Configure the computer environment variables or cloud environment variables by running the following command. Replace YOUR_SECRET_ID and YOUR_SECRET_KEY with your SecretId and SecretKey, respectively.
export TENCENTCLOUD_SECRET_ID=YOUR_SECRET_ID
export TENCENTCLOUD_SECRET_KEY=YOUR_SECRET_KEY

Incorporating Component Integration from the Integration Center of a Prometheus Instance

1. Creating a new Terraform configuration file: Create a new directory and a file named main.tf in the directory. The following is the configuration information:
#Specifying Provider Configuration Information

terraform { required_providers { tencentcloud = { source = "tencentcloudstack/tencentcloud" } } }

#Prometheus Managing Cloud Monitoring Integration

##black-box Integration
resource "tencentcloud_monitor_tmp_exporter_integration" "tmpExporterIntegration" {
instance_id = tencentcloud_monitor_tmp_instance.foo.id
kind = "blackbox-exporter"
content = "{\\"name\\":\\"balck-box-tf-test\\",\\"kind\\":\\"blackbox-exporter\\",\\"spec\\":{\\"instanceSpec\\":{\\"module\\":\\"http_get\\",\\"urls\\":[\\"http://baidu.com\\"]}}}"
kube_type = 1
cluster_id = ""
}

##Cloud Monitoring Plugin Integration
resource "tencentcloud_monitor_tmp_exporter_integration" "tmpExporterMointor" {
instance_id = tencentcloud_monitor_tmp_instance.foo.id
kind = "qcloud-exporter"
content = "{\\"name\\":\\"tf-test-cjtest\\",\\"kind\\":\\"qcloud-exporter\\",\\"spec\\":{\\"instanceSpec\\":{\\"region\\":\\"ap-guangzhou\\",\\"delaySeconds\\":0,\\"reload_interval_minutes\\":10,\\"useRole\\":true,\\"labels\\":{}},\\"exporterSpec\\":{\\"cvm\\":true,\\"cbs\\":false,\\"lb_public\\":true,\\"lb_private\\":false,\\"tgw_set\\":false,\\"cmongo\\":false,\\"cdb\\":false,\\"redis\\":false,\\"redis_mem\\":false,\\"mariadb\\":false,\\"postgres\\":false,\\"tdmysql\\":false,\\"cynosdb_mysql\\":false,\\"sqlserver\\":false,\\"nat_gateway\\":false,\\"ckafka\\":false,\\"rocketmq\\":false,\\"tdmq\\":false,\\"lb\\":false,\\"vpngw\\":false,\\"vpnx\\":false,\\"cdn\\":false,\\"ov_cdn\\":false,\\"cos\\":false,\\"dc\\":false,\\"dcx\\":false,\\"dcg\\":false,\\"lighthouse\\":false,\\"nacos\\":false,\\"zookeeper\\":false,\\"ces\\":false,\\"dts\\":false,\\"vbc\\":false,\\"gaap\\":false,\\"waf\\":false,\\"cfs\\":false,\\"bwp\\":false,\\"scf_v2\\":false,\\"vod\\":false,\\"cls\\":false,\\"apigateway\\":false,\\"self\\":false},\\"scrapeSpec\\":{\\"relabelConfigs\\":\\"metricRelabelings:\\\\n- action: labeldrop\\\\n regex: tmp_test_label\\\\n\\"}}}"
kube_type = 1
cluster_id = ""
}
Note:
The fields to be configured when you create the Integration Center component of the Prometheus instance are as follows:
cluster_id: (Required, string) Cluster ID.
content: (Required, string) Integration configuration (internal parameters within content can be replaced as needed).
instance_id: (Required, string) Instance ID.
kind: (Required, string) Type.
kube_type: (Required, integer) Integration configuration.
2. To initialize the Terraform runtime environment, run the following command:
terraform init
Expected output:
Initializing the backend...

Initializing provider plugins...
- Reusing previous version of tencentcloudstack/tencentcloud from the dependency lock file
- Using previously-installed tencentcloudstack/tencentcloud v1.81.32

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
3. To generate a resource plan, run the following command:
terraform plan
Expected output:
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
following symbols:
+ create

Terraform will perform the following actions:

# tencentcloud_monitor_tmp_exporter_integration.tmpExporterIntegration will be created
+ resource "tencentcloud_monitor_tmp_exporter_integration" "tmpExporterIntegration" {
+ content = jsonencode(
XXX...
)
+ id = (known after apply)
+ instance_id = (known after apply)
+ kind = "blackbox-exporter"
+ kube_type = 1
}

# tencentcloud_monitor_tmp_exporter_integration.tmpExporterMointor will be created
+ resource "tencentcloud_monitor_tmp_exporter_integration" "tmpExporterMointor" {
+ content = jsonencode(
XXX...
)
+ id = (known after apply)
+ instance_id = (known after apply)
+ kind = "qcloud-exporter"
+ kube_type = 1
}

# tencentcloud_monitor_tmp_instance.foo will be created
+ resource "tencentcloud_monitor_tmp_instance" "foo" {
+ api_root_path = (known after apply)
+ data_retention_time = 30
+ id = (known after apply)
+ instance_name = "tf-tmp-instance-sjtest"
+ ipv4_address = (known after apply)
+ proxy_address = (known after apply)
+ remote_write = (known after apply)
+ subnet_id = "subnet-es8rv1kx"
+ tags = {
+ "createdBy" = "terraform"
}
+ vpc_id = "vpc-0n42dxzs"
+ zone = "ap-mumbai-1"
}

Plan: 3 to add, 0 to change, 0 to destroy.

───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if
you run "terraform apply" now.
4. To create component integration of the Integration Center, run the following command:
terraform apply
Expected output:
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
following symbols:
+ create

Terraform will perform the following actions:
XXX...

Plan: 3 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.

Enter a value: yes

tencentcloud_monitor_tmp_instance.foo: Creating...
tencentcloud_monitor_tmp_instance.foo: Still creating... [10s elapsed]
...

Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
Note:
When the message "Apply complete! Resources: 3 added, 0 changed, 0 destroyed." is displayed, the creation is successful.

Viewing the Status of Prometheus Instances

Log in to the TCOP, and choose Managed Service for Prometheus from the left-hand navigation bar. Existing instances are displayed in the Prometheus instance list.

Deleting the Component Integration in the Prometheus Instance Integration Center

To terminate the resources, run the following command:
terraform destroy
Expected output:
tencentcloud_monitor_tmp_instance.foo: Refreshing state... [id=prom-8dyb6iny]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
following symbols:
- destroy

Terraform will perform the following actions:
XXX...

Plan: 0 to add, 0 to change, 1 to destroy.

Do you really want to destroy all resources?
Terraform will destroy all your managed infrastructure, as shown above.
There is no undo. Only 'yes' will be accepted to confirm.

Enter a value: yes

tencentcloud_monitor_tmp_instance.foo: Destroying... [id=prom-8dyb6iny]
tencentcloud_monitor_tmp_instance.foo: Destruction complete after 6s

Destroy complete! Resources: 1 destroyed.

Note:
When Destroy complete! Resources: 1 destroyed. is displayed, the instance has been successfully deleted.


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백