diff --git a/examples/tencentcloud-monitor-tke/main.tf b/examples/tencentcloud-monitor-tke/main.tf new file mode 100644 index 0000000000..f4ef565f79 --- /dev/null +++ b/examples/tencentcloud-monitor-tke/main.tf @@ -0,0 +1,251 @@ +# create tke +variable "default_instance_type" { + default = "SA1.MEDIUM2" +} + +variable "availability_zone_first" { + default = "ap-guangzhou-3" +} + +variable "availability_zone_second" { + default = "ap-guangzhou-4" +} + +variable "example_cluster_cidr" { + default = "10.31.0.0/16" +} + +locals { + first_vpc_id = data.tencentcloud_vpc_subnets.vpc_one.instance_list.0.vpc_id + first_subnet_id = data.tencentcloud_vpc_subnets.vpc_one.instance_list.0.subnet_id + second_vpc_id = data.tencentcloud_vpc_subnets.vpc_two.instance_list.0.vpc_id + second_subnet_id = data.tencentcloud_vpc_subnets.vpc_two.instance_list.0.subnet_id + sg_id = tencentcloud_security_group.sg.id + image_id = data.tencentcloud_images.default.image_id +} + +data "tencentcloud_vpc_subnets" "vpc_one" { + is_default = true + availability_zone = var.availability_zone_first +} + +data "tencentcloud_vpc_subnets" "vpc_two" { + is_default = true + availability_zone = var.availability_zone_second +} + +resource "tencentcloud_security_group" "sg" { + name = "tf-example-sg" +} + +resource "tencentcloud_security_group_lite_rule" "sg_rule" { + security_group_id = tencentcloud_security_group.sg.id + + ingress = [ + "ACCEPT#10.0.0.0/16#ALL#ALL", + "ACCEPT#172.16.0.0/22#ALL#ALL", + "DROP#0.0.0.0/0#ALL#ALL", + ] + + egress = [ + "ACCEPT#172.16.0.0/22#ALL#ALL", + ] +} + +data "tencentcloud_images" "default" { + image_type = ["PUBLIC_IMAGE"] + image_name_regex = "Final" +} + +resource "tencentcloud_kubernetes_cluster" "example" { + vpc_id = local.first_vpc_id + cluster_cidr = var.example_cluster_cidr + cluster_max_pod_num = 32 + cluster_name = "tf_example_cluster" + cluster_desc = "example for tke cluster" + cluster_max_service_num = 32 + cluster_internet = false + cluster_internet_security_group = local.sg_id + cluster_version = "1.22.5" + cluster_deploy_type = "MANAGED_CLUSTER" + + worker_config { + count = 1 + availability_zone = var.availability_zone_first + instance_type = var.default_instance_type + system_disk_type = "CLOUD_SSD" + system_disk_size = 60 + internet_charge_type = "TRAFFIC_POSTPAID_BY_HOUR" + internet_max_bandwidth_out = 100 + public_ip_assigned = true + subnet_id = local.first_subnet_id + img_id = local.image_id + + data_disk { + disk_type = "CLOUD_PREMIUM" + disk_size = 50 + } + + enhanced_security_service = false + enhanced_monitor_service = false + user_data = "dGVzdA==" + # key_ids = ["skey-11112222"] + password = "ZZXXccvv1212" // Optional, should be set if key_ids not set. + } + + worker_config { + count = 1 + availability_zone = var.availability_zone_second + instance_type = var.default_instance_type + system_disk_type = "CLOUD_SSD" + system_disk_size = 60 + internet_charge_type = "TRAFFIC_POSTPAID_BY_HOUR" + internet_max_bandwidth_out = 100 + public_ip_assigned = true + subnet_id = local.second_subnet_id + + data_disk { + disk_type = "CLOUD_PREMIUM" + disk_size = 50 + } + + enhanced_security_service = false + enhanced_monitor_service = false + user_data = "dGVzdA==" + # key_ids = ["skey-11112222"] + cam_role_name = "CVM_QcsRole" + password = "ZZXXccvv1212" // Optional, should be set if key_ids not set. + } + + labels = { + "test1" = "test1", + "test2" = "test2", + } +} + + +# create monitor +variable "zone" { + default = "ap-guangzhou" +} + +variable "cluster_type" { + default = "tke" +} + +resource "tencentcloud_monitor_tmp_instance" "foo" { + instance_name = "tf-tmp-instance" + vpc_id = local.first_vpc_id + subnet_id = local.first_subnet_id + data_retention_time = 30 + zone = var.availability_zone_second + tags = { + "createdBy" = "terraform" + } +} + + +# tmp tke bind +resource "tencentcloud_monitor_tmp_tke_cluster_agent" "foo" { + instance_id = tencentcloud_monitor_tmp_instance.foo.id + + agents { + region = var.zone + cluster_type = var.cluster_type + cluster_id = tencentcloud_kubernetes_cluster.example.id + enable_external = false + } +} + +# create monitor template +resource "tencentcloud_monitor_tmp_tke_template" "foo" { + template { + name = "tf-template" + level = "cluster" + describe = "template" + service_monitors { + name = "tf-ServiceMonitor" + config = <<-EOT +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: example-service-monitor + namespace: monitoring + labels: + k8s-app: example-service +spec: + selector: + matchLabels: + k8s-app: example-service + namespaceSelector: + matchNames: + - default + endpoints: + - port: http-metrics + interval: 30s + path: /metrics + scheme: http + bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token + tlsConfig: + insecureSkipVerify: true + EOT + } + + pod_monitors { + name = "tf-PodMonitors" + config = <<-EOT +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: example-pod-monitor + namespace: monitoring + labels: + k8s-app: example-pod +spec: + selector: + matchLabels: + k8s-app: example-pod + namespaceSelector: + matchNames: + - default + podMetricsEndpoints: + - port: http-metrics + interval: 30s + path: /metrics + scheme: http + bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token + tlsConfig: + insecureSkipVerify: true +EOT + } + + pod_monitors { + name = "tf-RawJobs" + config = <<-EOT +scrape_configs: + - job_name: 'example-job' + scrape_interval: 30s + static_configs: + - targets: ['example-service.default.svc.cluster.local:8080'] + metrics_path: /metrics + scheme: http + bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token + tls_config: + insecure_skip_verify: true +EOT + } + } +} + +resource "tencentcloud_monitor_tmp_tke_template_attachment" "temp_attachment" { + template_id = tencentcloud_monitor_tmp_tke_template.foo.id + + targets { + cluster_type = var.cluster_type + cluster_id = tencentcloud_kubernetes_cluster.example.id + region = var.zone + instance_id = tencentcloud_monitor_tmp_instance.foo.id + } + + depends_on = [tencentcloud_monitor_tmp_tke_cluster_agent.foo] +} \ No newline at end of file diff --git a/examples/tencentcloud-monitor-tke/version.tf b/examples/tencentcloud-monitor-tke/version.tf new file mode 100644 index 0000000000..133d0d73e7 --- /dev/null +++ b/examples/tencentcloud-monitor-tke/version.tf @@ -0,0 +1,3 @@ +terraform { + required_version = ">= 0.12" +} \ No newline at end of file diff --git a/examples/tencentcloud-monitor/main.tf b/examples/tencentcloud-monitor/main.tf index a4de0bf827..d7687c167b 100644 --- a/examples/tencentcloud-monitor/main.tf +++ b/examples/tencentcloud-monitor/main.tf @@ -1,40 +1,45 @@ -data "tencentcloud_cam_groups" "groups" { - //You should first create a user group with CAM +variable "availability_zone" { + default = "ap-guangzhou-4" } -data "tencentcloud_instances" "instances" { + +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_monitor_vpc" } -resource "tencentcloud_monitor_policy_group" "group" { - group_name = "nice_group" - policy_view_name = "cvm_device" - remark = "this is a test policy group" - conditions { - metric_id = 33 - alarm_notify_type = 1 - alarm_notify_period = 600 - calc_type = 1 - calc_value = 3 - calc_period = 300 - continue_period = 2 - } +resource "tencentcloud_subnet" "subnet" { + vpc_id = tencentcloud_vpc.vpc.id + availability_zone = var.availability_zone + name = "tf_monitor_subnet" + cidr_block = "10.0.1.0/24" } -#for cvm -resource "tencentcloud_monitor_binding_object" "binding" { - group_id = tencentcloud_monitor_policy_group.group.id - dimensions { - dimensions_json = "{\"unInstanceId\":\"${data.tencentcloud_instances.instances.instance_list[0].instance_id}\"}" + +resource "tencentcloud_monitor_tmp_instance" "foo" { + instance_name = "tf-tmp-instance" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + data_retention_time = 30 + zone = var.availability_zone + tags = { + "createdBy" = "terraform" } } -resource "tencentcloud_monitor_binding_receiver" "receiver" { - group_id = tencentcloud_monitor_policy_group.group.id - receivers { - start_time = 0 - end_time = 86399 - notify_way = ["SMS"] - receiver_type = "group" - receiver_group_list = [data.tencentcloud_cam_groups.groups.group_list[0].group_id] - receive_language = "en-US" +resource "tencentcloud_monitor_grafana_instance" "foo" { + instance_name = "tf-grafana" + vpc_id = tencentcloud_vpc.vpc.id + subnet_ids = [tencentcloud_subnet.subnet.id] + grafana_init_password = "1234567890" + enable_internet = false + is_destroy = true + + tags = { + "createdBy" = "test" } } + +resource "tencentcloud_monitor_tmp_manage_grafana_attachment" "foo" { + grafana_id = tencentcloud_monitor_grafana_instance.foo.id + instance_id = tencentcloud_monitor_tmp_instance.foo.id +} \ No newline at end of file diff --git a/tencentcloud/resource_tc_monitor_alarm_notice.go b/tencentcloud/resource_tc_monitor_alarm_notice.go index f726a395b5..8f680c7b67 100644 --- a/tencentcloud/resource_tc_monitor_alarm_notice.go +++ b/tencentcloud/resource_tc_monitor_alarm_notice.go @@ -4,8 +4,8 @@ Provides a alarm notice resource for monitor. Example Usage ```hcl -resource "tencentcloud_monitor_alarm_notice" "example" { - name = "test_alarm_notice_1" +resource "tencentcloud_monitor_alarm_notice" "foo" { + name = "tf-alarm_notice" notice_type = "ALL" notice_language = "zh-CN" diff --git a/tencentcloud/resource_tc_monitor_alarm_policy.go b/tencentcloud/resource_tc_monitor_alarm_policy.go index 09e93923f6..676c5db3d0 100644 --- a/tencentcloud/resource_tc_monitor_alarm_policy.go +++ b/tencentcloud/resource_tc_monitor_alarm_policy.go @@ -6,11 +6,41 @@ Example Usage cvm_device alarm policy ```hcl -resource "tencentcloud_monitor_alarm_policy" "group" { - policy_name = "hello" +resource "tencentcloud_monitor_alarm_notice" "foo" { + name = "tf-alarm_notice" + notice_type = "ALL" + notice_language = "zh-CN" + + user_notices { + receiver_type = "USER" + start_time = 0 + end_time = 1 + notice_way = ["SMS","EMAIL"] + user_ids = [10001] + group_ids = [] + phone_order = [10001] + phone_circle_times = 2 + phone_circle_interval = 50 + phone_inner_interval = 60 + need_phone_arrive_notice = 1 + phone_call_type = "CIRCLE" + weekday =[1,2,3,4,5,6,7] + } + + url_notices { + url = "https://www.mytest.com/validate" + end_time = 0 + start_time = 1 + weekday = [1,2,3,4,5,6,7] + } + +} + +resource "tencentcloud_monitor_alarm_policy" "foo" { + policy_name = "tf-policy" monitor_type = "MT_QCE" enable = 1 - project_id = 1244035 + project_id = 0 namespace = "cvm_device" conditions { is_union_rule = 1 @@ -30,7 +60,7 @@ resource "tencentcloud_monitor_alarm_policy" "group" { event_conditions { metric_name = "guest_reboot" } - notice_ids = ["notice-l9ziyxw6"] + notice_ids = [tencentcloud_monitor_alarm_notice.foo.id] trigger_tasks { type = "AS" diff --git a/tencentcloud/resource_tc_monitor_tmp_alert_rule.go b/tencentcloud/resource_tc_monitor_tmp_alert_rule.go index b7afdf0022..24c6661867 100644 --- a/tencentcloud/resource_tc_monitor_tmp_alert_rule.go +++ b/tencentcloud/resource_tc_monitor_tmp_alert_rule.go @@ -4,23 +4,63 @@ Provides a resource to create a monitor tmpAlertRule Example Usage ```hcl -resource "tencentcloud_monitor_tmp_alert_rule" "tmpAlertRule" { - instance_id = "prom-c89b3b3u" - rule_name = "test123" - expr = "up{service=\"rig-prometheus-agent\"}>0" - receivers = ["notice-l9ziyxw6"] - rule_state = 2 - duration = "4m" - labels { - key = "hello1" - value = "world1" - } - annotations { - key = "hello2" - value = "world2" +variable "availability_zone" { + default = "ap-guangzhou-4" +} + +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_monitor_vpc" +} + +resource "tencentcloud_subnet" "subnet" { + vpc_id = tencentcloud_vpc.vpc.id + availability_zone = var.availability_zone + name = "tf_monitor_subnet" + cidr_block = "10.0.1.0/24" +} + + +resource "tencentcloud_monitor_tmp_instance" "foo" { + instance_name = "tf-tmp-instance" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + data_retention_time = 30 + zone = var.availability_zone + tags = { + "createdBy" = "terraform" } } +resource "tencentcloud_monitor_tmp_cvm_agent" "foo" { + instance_id = tencentcloud_monitor_tmp_instance.foo.id + name = "tf-agent" +} + +resource "tencentcloud_monitor_tmp_alert_rule" "foo" { + duration = "2m" + expr = "avg by (instance) (mysql_global_status_threads_connected) / avg by (instance) (mysql_global_variables_max_connections) > 0.8" + instance_id = tencentcloud_monitor_tmp_instance.foo.id + receivers = ["notice-f2svbu3w"] + rule_name = "MySQL 连接数过多" + rule_state = 2 + type = "MySQL/MySQL 连接数过多" + + annotations { + key = "description" + value = "MySQL 连接数过多, 实例: {{$labels.instance}},当前值: {{ $value | humanizePercentage }}。" + } + annotations { + key = "summary" + value = "MySQL 连接数过多(>80%)" + } + + labels { + key = "severity" + value = "warning" + } +} + ``` Import diff --git a/tencentcloud/resource_tc_monitor_tmp_cvm_agent.go b/tencentcloud/resource_tc_monitor_tmp_cvm_agent.go index 6fb46d62d5..0a4d47c8b9 100644 --- a/tencentcloud/resource_tc_monitor_tmp_cvm_agent.go +++ b/tencentcloud/resource_tc_monitor_tmp_cvm_agent.go @@ -4,9 +4,37 @@ Provides a resource to create a monitor tmpCvmAgent Example Usage ```hcl -resource "tencentcloud_monitor_tmp_cvm_agent" "tmpCvmAgent" { - instance_id = "prom-dko9d0nu" - name = "agent" +variable "availability_zone" { + default = "ap-guangzhou-4" +} + +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_monitor_vpc" +} + +resource "tencentcloud_subnet" "subnet" { + vpc_id = tencentcloud_vpc.vpc.id + availability_zone = var.availability_zone + name = "tf_monitor_subnet" + cidr_block = "10.0.1.0/24" +} + + +resource "tencentcloud_monitor_tmp_instance" "foo" { + instance_name = "tf-tmp-instance" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + data_retention_time = 30 + zone = var.availability_zone + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_monitor_tmp_cvm_agent" "foo" { + instance_id = tencentcloud_monitor_tmp_instance.foo.id + name = "tf-agent" } ``` diff --git a/tencentcloud/resource_tc_monitor_tmp_grafana_config.go b/tencentcloud/resource_tc_monitor_tmp_grafana_config.go index 46b201dc3a..b901057ed1 100644 --- a/tencentcloud/resource_tc_monitor_tmp_grafana_config.go +++ b/tencentcloud/resource_tc_monitor_tmp_grafana_config.go @@ -4,17 +4,46 @@ Provides a resource to create a monitor tmp_grafana_config Example Usage ```hcl -resource "tencentcloud_monitor_tmp_grafana_config" "tmp_grafana_config" { - config = jsonencode( - { - server = { - http_port = 8080 - root_url = "https://cloud-grafana.woa.com/grafana-ffrdnrfa/" - serve_from_sub_path = true - } - } - ) - instance_id = "grafana-29phe08q" +variable "availability_zone" { + default = "ap-guangzhou-4" +} + +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_monitor_vpc" +} + +resource "tencentcloud_subnet" "subnet" { + vpc_id = tencentcloud_vpc.vpc.id + availability_zone = var.availability_zone + name = "tf_monitor_subnet" + cidr_block = "10.0.1.0/24" +} + +resource "tencentcloud_monitor_grafana_instance" "foo" { + instance_name = "tf-grafana" + vpc_id = tencentcloud_vpc.vpc.id + subnet_ids = [tencentcloud_subnet.subnet.id] + grafana_init_password = "1234567890" + enable_internet = false + is_destroy = true + + tags = { + "createdBy" = "test" + } +} + +resource "tencentcloud_monitor_tmp_grafana_config" "foo" { + config = jsonencode( + { + server = { + http_port = 8080 + root_url = "https://cloud-grafana.woa.com/grafana-ffrdnrfa/" + serve_from_sub_path = true + } + } + ) + instance_id = tencentcloud_monitor_grafana_instance.foo.id } ``` diff --git a/tencentcloud/resource_tc_monitor_tmp_instance.go b/tencentcloud/resource_tc_monitor_tmp_instance.go index 06e29e3188..037b3817c5 100644 --- a/tencentcloud/resource_tc_monitor_tmp_instance.go +++ b/tencentcloud/resource_tc_monitor_tmp_instance.go @@ -4,12 +4,29 @@ Provides a resource to create a monitor tmpInstance Example Usage ```hcl -resource "tencentcloud_monitor_tmp_instance" "tmpInstance" { - instance_name = "demo" - vpc_id = "vpc-2hfyray3" - subnet_id = "subnet-rdkj0agk" +variable "availability_zone" { + default = "ap-guangzhou-4" +} + +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_monitor_vpc" +} + +resource "tencentcloud_subnet" "subnet" { + vpc_id = tencentcloud_vpc.vpc.id + availability_zone = var.availability_zone + name = "tf_monitor_subnet" + cidr_block = "10.0.1.0/24" +} + + +resource "tencentcloud_monitor_tmp_instance" "foo" { + instance_name = "tf-tmp-instance" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id data_retention_time = 30 - zone = "ap-guangzhou-3" + zone = var.availability_zone tags = { "createdBy" = "terraform" } diff --git a/tencentcloud/resource_tc_monitor_tmp_manage_grafana_attachment.go b/tencentcloud/resource_tc_monitor_tmp_manage_grafana_attachment.go index 38d1192f4a..73bf614599 100644 --- a/tencentcloud/resource_tc_monitor_tmp_manage_grafana_attachment.go +++ b/tencentcloud/resource_tc_monitor_tmp_manage_grafana_attachment.go @@ -4,9 +4,50 @@ Provides a resource to create a monitor tmp_manage_grafana_attachment Example Usage ```hcl -resource "tencentcloud_monitor_tmp_manage_grafana_attachment" "manage_grafana_attachment" { - grafana_id = "grafana-xxxxxx" - instance_id = "prom-xxxxxxxx" +variable "availability_zone" { + default = "ap-guangzhou-4" +} + +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_monitor_vpc" +} + +resource "tencentcloud_subnet" "subnet" { + vpc_id = tencentcloud_vpc.vpc.id + availability_zone = var.availability_zone + name = "tf_monitor_subnet" + cidr_block = "10.0.1.0/24" +} + + +resource "tencentcloud_monitor_tmp_instance" "foo" { + instance_name = "tf-tmp-instance" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + data_retention_time = 30 + zone = var.availability_zone + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_monitor_grafana_instance" "foo" { + instance_name = "tf-grafana" + vpc_id = tencentcloud_vpc.vpc.id + subnet_ids = [tencentcloud_subnet.subnet.id] + grafana_init_password = "1234567890" + enable_internet = false + is_destroy = true + + tags = { + "createdBy" = "test" + } +} + +resource "tencentcloud_monitor_tmp_manage_grafana_attachment" "foo" { + grafana_id = tencentcloud_monitor_grafana_instance.foo.id + instance_id = tencentcloud_monitor_tmp_instance.foo.id } ``` diff --git a/tencentcloud/resource_tc_monitor_tmp_recording_rule.go b/tencentcloud/resource_tc_monitor_tmp_recording_rule.go index 7497579e16..7ae11fe334 100644 --- a/tencentcloud/resource_tc_monitor_tmp_recording_rule.go +++ b/tencentcloud/resource_tc_monitor_tmp_recording_rule.go @@ -4,17 +4,45 @@ Provides a resource to create a monitor tmp recordingRule Example Usage ```hcl +variable "availability_zone" { + default = "ap-guangzhou-4" +} + +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_monitor_vpc" +} + +resource "tencentcloud_subnet" "subnet" { + vpc_id = tencentcloud_vpc.vpc.id + availability_zone = var.availability_zone + name = "tf_monitor_subnet" + cidr_block = "10.0.1.0/24" +} + +resource "tencentcloud_monitor_tmp_instance" "foo" { + instance_name = "tf-tmp-instance" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + data_retention_time = 30 + zone = var.availability_zone + tags = { + "createdBy" = "terraform" + } +} + resource "tencentcloud_monitor_tmp_recording_rule" "recordingRule" { - name = "dasdasdsadasd" - group = <0" - receivers = ["notice-l9ziyxw6"] +variable "availability_zone" { + default = "ap-guangzhou-4" +} + +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_monitor_vpc" +} + +resource "tencentcloud_subnet" "subnet" { + vpc_id = tencentcloud_vpc.vpc.id + availability_zone = var.availability_zone + name = "tf_monitor_subnet" + cidr_block = "10.0.1.0/24" +} + +resource "tencentcloud_monitor_tmp_instance" "foo" { + instance_name = "tf-tmp-instance" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + data_retention_time = 30 + zone = var.availability_zone + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_monitor_tmp_cvm_agent" "foo" { + instance_id = tencentcloud_monitor_tmp_instance.foo.id + name = "tf-agent" +} + +resource "tencentcloud_monitor_tmp_alert_rule" "foo" { + duration = "2m" + expr = "avg by (instance) (mysql_global_status_threads_connected) / avg by (instance) (mysql_global_variables_max_connections) > 0.8" + instance_id = tencentcloud_monitor_tmp_instance.foo.id + receivers = ["notice-f2svbu3w"] + rule_name = "MySQL 连接数过多" rule_state = 2 - duration = "4m" - labels { - key = "hello1" - value = "world1" + type = "MySQL/MySQL 连接数过多" + + annotations { + key = "description" + value = "MySQL 连接数过多, 实例: {{$labels.instance}},当前值: {{ $value | humanizePercentage }}。" } annotations { - key = "hello2" - value = "world2" + key = "summary" + value = "MySQL 连接数过多(>80%)" + } + + labels { + key = "severity" + value = "warning" } } ``` diff --git a/website/docs/r/monitor_tmp_cvm_agent.html.markdown b/website/docs/r/monitor_tmp_cvm_agent.html.markdown index 8cb679f72c..0450010868 100644 --- a/website/docs/r/monitor_tmp_cvm_agent.html.markdown +++ b/website/docs/r/monitor_tmp_cvm_agent.html.markdown @@ -14,9 +14,36 @@ Provides a resource to create a monitor tmpCvmAgent ## Example Usage ```hcl -resource "tencentcloud_monitor_tmp_cvm_agent" "tmpCvmAgent" { - instance_id = "prom-dko9d0nu" - name = "agent" +variable "availability_zone" { + default = "ap-guangzhou-4" +} + +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_monitor_vpc" +} + +resource "tencentcloud_subnet" "subnet" { + vpc_id = tencentcloud_vpc.vpc.id + availability_zone = var.availability_zone + name = "tf_monitor_subnet" + cidr_block = "10.0.1.0/24" +} + +resource "tencentcloud_monitor_tmp_instance" "foo" { + instance_name = "tf-tmp-instance" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + data_retention_time = 30 + zone = var.availability_zone + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_monitor_tmp_cvm_agent" "foo" { + instance_id = tencentcloud_monitor_tmp_instance.foo.id + name = "tf-agent" } ``` diff --git a/website/docs/r/monitor_tmp_grafana_config.html.markdown b/website/docs/r/monitor_tmp_grafana_config.html.markdown index 38a2138919..6308b77a1b 100644 --- a/website/docs/r/monitor_tmp_grafana_config.html.markdown +++ b/website/docs/r/monitor_tmp_grafana_config.html.markdown @@ -14,7 +14,36 @@ Provides a resource to create a monitor tmp_grafana_config ## Example Usage ```hcl -resource "tencentcloud_monitor_tmp_grafana_config" "tmp_grafana_config" { +variable "availability_zone" { + default = "ap-guangzhou-4" +} + +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_monitor_vpc" +} + +resource "tencentcloud_subnet" "subnet" { + vpc_id = tencentcloud_vpc.vpc.id + availability_zone = var.availability_zone + name = "tf_monitor_subnet" + cidr_block = "10.0.1.0/24" +} + +resource "tencentcloud_monitor_grafana_instance" "foo" { + instance_name = "tf-grafana" + vpc_id = tencentcloud_vpc.vpc.id + subnet_ids = [tencentcloud_subnet.subnet.id] + grafana_init_password = "1234567890" + enable_internet = false + is_destroy = true + + tags = { + "createdBy" = "test" + } +} + +resource "tencentcloud_monitor_tmp_grafana_config" "foo" { config = jsonencode( { server = { @@ -24,7 +53,7 @@ resource "tencentcloud_monitor_tmp_grafana_config" "tmp_grafana_config" { } } ) - instance_id = "grafana-29phe08q" + instance_id = tencentcloud_monitor_grafana_instance.foo.id } ``` diff --git a/website/docs/r/monitor_tmp_instance.html.markdown b/website/docs/r/monitor_tmp_instance.html.markdown index d61d502748..24f32a4f28 100644 --- a/website/docs/r/monitor_tmp_instance.html.markdown +++ b/website/docs/r/monitor_tmp_instance.html.markdown @@ -14,12 +14,28 @@ Provides a resource to create a monitor tmpInstance ## Example Usage ```hcl -resource "tencentcloud_monitor_tmp_instance" "tmpInstance" { - instance_name = "demo" - vpc_id = "vpc-2hfyray3" - subnet_id = "subnet-rdkj0agk" +variable "availability_zone" { + default = "ap-guangzhou-4" +} + +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_monitor_vpc" +} + +resource "tencentcloud_subnet" "subnet" { + vpc_id = tencentcloud_vpc.vpc.id + availability_zone = var.availability_zone + name = "tf_monitor_subnet" + cidr_block = "10.0.1.0/24" +} + +resource "tencentcloud_monitor_tmp_instance" "foo" { + instance_name = "tf-tmp-instance" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id data_retention_time = 30 - zone = "ap-guangzhou-3" + zone = var.availability_zone tags = { "createdBy" = "terraform" } diff --git a/website/docs/r/monitor_tmp_manage_grafana_attachment.html.markdown b/website/docs/r/monitor_tmp_manage_grafana_attachment.html.markdown index 4c941621ad..4feb89c570 100644 --- a/website/docs/r/monitor_tmp_manage_grafana_attachment.html.markdown +++ b/website/docs/r/monitor_tmp_manage_grafana_attachment.html.markdown @@ -14,9 +14,49 @@ Provides a resource to create a monitor tmp_manage_grafana_attachment ## Example Usage ```hcl -resource "tencentcloud_monitor_tmp_manage_grafana_attachment" "manage_grafana_attachment" { - grafana_id = "grafana-xxxxxx" - instance_id = "prom-xxxxxxxx" +variable "availability_zone" { + default = "ap-guangzhou-4" +} + +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_monitor_vpc" +} + +resource "tencentcloud_subnet" "subnet" { + vpc_id = tencentcloud_vpc.vpc.id + availability_zone = var.availability_zone + name = "tf_monitor_subnet" + cidr_block = "10.0.1.0/24" +} + +resource "tencentcloud_monitor_tmp_instance" "foo" { + instance_name = "tf-tmp-instance" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + data_retention_time = 30 + zone = var.availability_zone + tags = { + "createdBy" = "terraform" + } +} + +resource "tencentcloud_monitor_grafana_instance" "foo" { + instance_name = "tf-grafana" + vpc_id = tencentcloud_vpc.vpc.id + subnet_ids = [tencentcloud_subnet.subnet.id] + grafana_init_password = "1234567890" + enable_internet = false + is_destroy = true + + tags = { + "createdBy" = "test" + } +} + +resource "tencentcloud_monitor_tmp_manage_grafana_attachment" "foo" { + grafana_id = tencentcloud_monitor_grafana_instance.foo.id + instance_id = tencentcloud_monitor_tmp_instance.foo.id } ``` diff --git a/website/docs/r/monitor_tmp_recording_rule.html.markdown b/website/docs/r/monitor_tmp_recording_rule.html.markdown index 5cbb68d5d3..c40f9ceeae 100644 --- a/website/docs/r/monitor_tmp_recording_rule.html.markdown +++ b/website/docs/r/monitor_tmp_recording_rule.html.markdown @@ -14,8 +14,37 @@ Provides a resource to create a monitor tmp recordingRule ## Example Usage ```hcl +variable "availability_zone" { + default = "ap-guangzhou-4" +} + +resource "tencentcloud_vpc" "vpc" { + cidr_block = "10.0.0.0/16" + name = "tf_monitor_vpc" +} + +resource "tencentcloud_subnet" "subnet" { + vpc_id = tencentcloud_vpc.vpc.id + availability_zone = var.availability_zone + name = "tf_monitor_subnet" + cidr_block = "10.0.1.0/24" +} + +resource "tencentcloud_monitor_tmp_instance" "foo" { + instance_name = "tf-tmp-instance" + vpc_id = tencentcloud_vpc.vpc.id + subnet_id = tencentcloud_subnet.subnet.id + data_retention_time = 30 + zone = var.availability_zone + tags = { + "createdBy" = "terraform" + } +} + resource "tencentcloud_monitor_tmp_recording_rule" "recordingRule" { - name = "dasdasdsadasd" + instance_id = tencentcloud_monitor_tmp_instance.foo.id + rule_state = 2 + name = "tf-recording-rule" group = <