Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
SevenEarth committed Jan 22, 2025
1 parent 25fef0f commit 12749c4
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"strconv"
"strings"

tke "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke/v20180525"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
monitor "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/monitor/v20180724"
Expand Down Expand Up @@ -101,10 +99,10 @@ func resourceTencentCloudMonitorTmpExporterIntegrationCreate(d *schema.ResourceD
request.ClusterId = helper.String(clusterId)
}

initStatus := tke.NewDescribePrometheusInstanceInitStatusRequest()
initStatus := monitor.NewDescribePrometheusInstanceInitStatusRequest()
initStatus.InstanceId = request.InstanceId
err := resource.Retry(8*tccommon.ReadRetryTimeout, func() *resource.RetryError {
results, errRet := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseTkeClient().DescribePrometheusInstanceInitStatus(initStatus)
results, errRet := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseMonitorClient().DescribePrometheusInstanceInitStatus(initStatus)
if errRet != nil {
return tccommon.RetryError(errRet, tccommon.InternalError)
}
Expand All @@ -116,10 +114,10 @@ func resourceTencentCloudMonitorTmpExporterIntegrationCreate(d *schema.ResourceD
return nil
}
if *status == "uninitialized" {
iniRequest := tke.NewRunPrometheusInstanceRequest()
iniRequest := monitor.NewRunPrometheusInstanceRequest()
iniRequest.InstanceId = request.InstanceId
err := resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseTkeClient().RunPrometheusInstance(iniRequest)
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseMonitorClient().RunPrometheusInstance(iniRequest)
if e != nil {
return tccommon.RetryError(e)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,43 @@ Provides a resource to create a monitor tmpExporterIntegration

Example Usage

Use blackbox-exporter
Use qcloud-exporter

```hcl
resource "tencentcloud_monitor_tmp_exporter_integration" "tmpExporterIntegration" {
instance_id = "prom-dko9d0nu"
kind = "blackbox-exporter"
content = "{\"name\":\"test\",\"kind\":\"blackbox-exporter\",\"spec\":{\"instanceSpec\":{\"module\":\"http_get\",\"urls\":[\"xx\"]}}}"
kube_type = 1
cluster_id = "cls-bmuaukfu"
resource "tencentcloud_monitor_tmp_exporter_integration" "example" {
instance_id = "prom-gzg3f1em"
kind = "qcloud-exporter"
content = "{\"name\":\"test\",\"kind\":\"qcloud-exporter\",\"spec\":{\"scrapeSpec\":{\"interval\":\"1m\",\"timeout\":\"1m\",\"relabelConfigs\":\"#metricRelabelings:\\n#- action: labeldrop\\n# regex: tmp_test_label\\n\"},\"instanceSpec\":{\"region\":\"Guangzhou\",\"role\":\"CM_QCSLinkedRoleInTMP\",\"useRole\":true,\"authProvider\":{\"method\":1,\"presetRole\":\"CM_QCSLinkedRoleInTMP\"},\"rateLimit\":1000,\"delaySeconds\":0,\"rangeSeconds\":0,\"reload_interval_minutes\":10,\"uin\":\"100023201586\",\"tag_key_operation\":\"ToUnderLineAndLower\"},\"exporterSpec\":{\"cvm\":false,\"cbs\":true,\"imageRegistry\":\"ccr.ccs.tencentyun.com\",\"cpu\":\"0.25\",\"memory\":\"0.5Gi\"}},\"status\":{}}"
cluster_id = "cls-csxm4phu"
kube_type = 3
}
```

Use es-exporter

```
resource "tencentcloud_monitor_tmp_exporter_integration" "tmpExporterIntegrationEs" {
instance_id = tencentcloud_monitor_tmp_instance.tmpInstance.id
resource "tencentcloud_monitor_tmp_exporter_integration" "example" {
instance_id = "prom-gzg3f1em"
kind = "es-exporter"
content = jsonencode({
"name": "ex-exporter-example",
"kind": "es-exporter",
"spec": {
"instanceSpec": {
"url": "http://127.0.0.1:9123",
"labels": {
"instance": "es-abcd"
},
"version": "1.70.1",
"user": "fugiat Duis minim",
"password": "exercitation cillum velit"
"name" : "ex-exporter-example",
"kind" : "es-exporter",
"spec" : {
"instanceSpec" : {
"user" : "root",
"password" : "Password@123"
"url" : "http://127.0.0.1:8080",
"labels" : {
"labelKey" : "labelValue"
}
},
"exporterSpec": {
"all": true,
"indicesSettings": false,
"snapshots": false,
"indices": true,
"shards": false
"exporterSpec" : {
"all" : true,
"indices" : true,
"indicesSettings" : true,
"shards" : true,
"snapshots" : true,
"clusterSettings" : true
}
}
})
Expand All @@ -53,36 +53,36 @@ Integration Center: CVM Scrape Job

```
resource "tencentcloud_vpc" "vpc" {
name = "tf-eks-vpc"
name = "vpc"
cidr_block = "10.2.0.0/16"
}
resource "tencentcloud_subnet" "sub" {
resource "tencentcloud_subnet" "subnet" {
vpc_id = tencentcloud_vpc.vpc.id
name = "tf-as-subnet"
name = "subnet"
cidr_block = "10.2.11.0/24"
availability_zone = "ap-guangzhou-3"
availability_zone = "ap-guangzhou-6"
}
resource "tencentcloud_monitor_tmp_instance" "tmpInstance" {
instance_name = "tf-test-tmp"
resource "tencentcloud_monitor_tmp_instance" "example" {
instance_name = "tf-example"
vpc_id = tencentcloud_vpc.vpc.id
subnet_id = tencentcloud_subnet.sub.id
subnet_id = tencentcloud_subnet.subnet.id
data_retention_time = 15
zone = "ap-guangzhou-3"
zone = "ap-guangzhou-6"
tags = {
"createdBy" = "terraform"
createdBy = "Terraform"
}
}
# Integration Center: CVM Scrape Job
resource "tencentcloud_monitor_tmp_exporter_integration" "tmpExporterIntegration" {
instance_id = tencentcloud_monitor_tmp_instance.tmpInstance.id
resource "tencentcloud_monitor_tmp_exporter_integration" "example" {
instance_id = tencentcloud_monitor_tmp_instance.example.id
kind = "cvm-http-sd-exporter"
content = jsonencode({
"kind": "cvm-http-sd-exporter",
"spec": {
"job": <<-EOT
content = jsonencode({
"kind" : "cvm-http-sd-exporter",
"spec" : {
"job" : <<-EOT
job_name: example-cvm-job-name
metrics_path: /metrics
cvm_sd_configs:
Expand All @@ -106,7 +106,7 @@ resource "tencentcloud_monitor_tmp_exporter_integration" "tmpExporterIntegration
EOT
}
})
kube_type = 3
cluster_id = ""
cluster_id = ""
kube_type = 3
}
```
60 changes: 30 additions & 30 deletions website/docs/r/monitor_tmp_exporter_integration.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,43 @@ Provides a resource to create a monitor tmpExporterIntegration

## Example Usage

### Use blackbox-exporter
### Use qcloud-exporter

```hcl
resource "tencentcloud_monitor_tmp_exporter_integration" "tmpExporterIntegration" {
instance_id = "prom-dko9d0nu"
kind = "blackbox-exporter"
content = "{\"name\":\"test\",\"kind\":\"blackbox-exporter\",\"spec\":{\"instanceSpec\":{\"module\":\"http_get\",\"urls\":[\"xx\"]}}}"
kube_type = 1
cluster_id = "cls-bmuaukfu"
resource "tencentcloud_monitor_tmp_exporter_integration" "example" {
instance_id = "prom-gzg3f1em"
kind = "qcloud-exporter"
content = "{\"name\":\"test\",\"kind\":\"qcloud-exporter\",\"spec\":{\"scrapeSpec\":{\"interval\":\"1m\",\"timeout\":\"1m\",\"relabelConfigs\":\"#metricRelabelings:\\n#- action: labeldrop\\n# regex: tmp_test_label\\n\"},\"instanceSpec\":{\"region\":\"Guangzhou\",\"role\":\"CM_QCSLinkedRoleInTMP\",\"useRole\":true,\"authProvider\":{\"method\":1,\"presetRole\":\"CM_QCSLinkedRoleInTMP\"},\"rateLimit\":1000,\"delaySeconds\":0,\"rangeSeconds\":0,\"reload_interval_minutes\":10,\"uin\":\"100023201586\",\"tag_key_operation\":\"ToUnderLineAndLower\"},\"exporterSpec\":{\"cvm\":false,\"cbs\":true,\"imageRegistry\":\"ccr.ccs.tencentyun.com\",\"cpu\":\"0.25\",\"memory\":\"0.5Gi\"}},\"status\":{}}"
cluster_id = "cls-csxm4phu"
kube_type = 3
}
```

### Use es-exporter

```hcl
resource "tencentcloud_monitor_tmp_exporter_integration" "tmpExporterIntegrationEs" {
instance_id = tencentcloud_monitor_tmp_instance.tmpInstance.id
resource "tencentcloud_monitor_tmp_exporter_integration" "example" {
instance_id = "prom-gzg3f1em"
kind = "es-exporter"
content = jsonencode({
"name" : "ex-exporter-example",
"kind" : "es-exporter",
"spec" : {
"instanceSpec" : {
"url" : "http://127.0.0.1:9123",
"user" : "root",
"password" : "Password@123"
"url" : "http://127.0.0.1:8080",
"labels" : {
"instance" : "es-abcd"
},
"version" : "1.70.1",
"user" : "fugiat Duis minim",
"password" : "exercitation cillum velit"
"labelKey" : "labelValue"
}
},
"exporterSpec" : {
"all" : true,
"indicesSettings" : false,
"snapshots" : false,
"indices" : true,
"shards" : false
"indicesSettings" : true,
"shards" : true,
"snapshots" : true,
"clusterSettings" : true
}
}
})
Expand All @@ -64,31 +64,31 @@ resource "tencentcloud_monitor_tmp_exporter_integration" "tmpExporterIntegration

```hcl
resource "tencentcloud_vpc" "vpc" {
name = "tf-eks-vpc"
name = "vpc"
cidr_block = "10.2.0.0/16"
}
resource "tencentcloud_subnet" "sub" {
resource "tencentcloud_subnet" "subnet" {
vpc_id = tencentcloud_vpc.vpc.id
name = "tf-as-subnet"
name = "subnet"
cidr_block = "10.2.11.0/24"
availability_zone = "ap-guangzhou-3"
availability_zone = "ap-guangzhou-6"
}
resource "tencentcloud_monitor_tmp_instance" "tmpInstance" {
instance_name = "tf-test-tmp"
resource "tencentcloud_monitor_tmp_instance" "example" {
instance_name = "tf-example"
vpc_id = tencentcloud_vpc.vpc.id
subnet_id = tencentcloud_subnet.sub.id
subnet_id = tencentcloud_subnet.subnet.id
data_retention_time = 15
zone = "ap-guangzhou-3"
zone = "ap-guangzhou-6"
tags = {
"createdBy" = "terraform"
createdBy = "Terraform"
}
}
# Integration Center: CVM Scrape Job
resource "tencentcloud_monitor_tmp_exporter_integration" "tmpExporterIntegration" {
instance_id = tencentcloud_monitor_tmp_instance.tmpInstance.id
resource "tencentcloud_monitor_tmp_exporter_integration" "example" {
instance_id = tencentcloud_monitor_tmp_instance.example.id
kind = "cvm-http-sd-exporter"
content = jsonencode({
"kind" : "cvm-http-sd-exporter",
Expand Down Expand Up @@ -117,8 +117,8 @@ resource "tencentcloud_monitor_tmp_exporter_integration" "tmpExporterIntegration
EOT
}
})
kube_type = 3
cluster_id = ""
kube_type = 3
}
```

Expand Down

0 comments on commit 12749c4

Please sign in to comment.