From f274d0525f8f3531aeafa96a30a4d2c7eb5b36fc Mon Sep 17 00:00:00 2001 From: rforstner Date: Tue, 19 Apr 2022 13:13:47 +0200 Subject: [PATCH] adding central alerting & notification --- .../alerting_profiles/SLO_Alerting_Central.tf | 18 +++++++++ CN_PROD/alerting_profiles/__main.tf | 26 +++++++++++++ .../SLO_Alerting_Central.tf | 17 +++++++++ CN_PROD/problem_notification/__main.tf | 37 +++++++++++++++++++ .../alerting_profiles/SLO_Alerting_Central.tf | 18 +++++++++ EMEA_PROD/alerting_profiles/__main.tf | 26 +++++++++++++ .../SLO_Alerting_Central.tf | 17 +++++++++ EMEA_PROD/problem_notification/__main.tf | 37 +++++++++++++++++++ .../alerting_profiles/SLO_Alerting_Central.tf | 18 +++++++++ NA_PROD/alerting_profiles/__main.tf | 26 +++++++++++++ .../SLO_Alerting_Central.tf | 17 +++++++++ NA_PROD/problem_notification/__main.tf | 37 +++++++++++++++++++ 12 files changed, 294 insertions(+) create mode 100644 CN_PROD/alerting_profiles/SLO_Alerting_Central.tf create mode 100644 CN_PROD/alerting_profiles/__main.tf create mode 100644 CN_PROD/problem_notification/SLO_Alerting_Central.tf create mode 100644 CN_PROD/problem_notification/__main.tf create mode 100644 EMEA_PROD/alerting_profiles/SLO_Alerting_Central.tf create mode 100644 EMEA_PROD/alerting_profiles/__main.tf create mode 100644 EMEA_PROD/problem_notification/SLO_Alerting_Central.tf create mode 100644 EMEA_PROD/problem_notification/__main.tf create mode 100644 NA_PROD/alerting_profiles/SLO_Alerting_Central.tf create mode 100644 NA_PROD/alerting_profiles/__main.tf create mode 100644 NA_PROD/problem_notification/SLO_Alerting_Central.tf create mode 100644 NA_PROD/problem_notification/__main.tf diff --git a/CN_PROD/alerting_profiles/SLO_Alerting_Central.tf b/CN_PROD/alerting_profiles/SLO_Alerting_Central.tf new file mode 100644 index 0000000..f3981c6 --- /dev/null +++ b/CN_PROD/alerting_profiles/SLO_Alerting_Central.tf @@ -0,0 +1,18 @@ +resource "dynatrace_alerting_profile" "SLO_Alerting_Central" { + display_name = "SLO_Alerting_Central" + event_type_filters { + custom_event_filter { + custom_title_filter { + enabled = true + case_insensitive = true + # negate = false + operator = "CONTAINS" + value = "TP_" + } + } + } +} + +output "SLO_Alerting_Central_id" { + value = dynatrace_alerting_profile.SLO_Alerting_Central.id +} diff --git a/CN_PROD/alerting_profiles/__main.tf b/CN_PROD/alerting_profiles/__main.tf new file mode 100644 index 0000000..cf6b82c --- /dev/null +++ b/CN_PROD/alerting_profiles/__main.tf @@ -0,0 +1,26 @@ +terraform { + required_providers { + dynatrace = { + version = "1.11.0" + source = "dynatrace-oss/dynatrace" + } + } + + backend "s3" { + bucket = "coco-dynatrace-tfstate" + key = "cnprod/alerting_profiles/terraform.tfstate" + region = "eu-central-1" + dynamodb_table = "coco-dynatrace-tfstate" + encrypt = true + } + +} + +variable CN_PROD_ENV_URL {} +variable CN_PROD_API_TOKEN {} + + +provider "dynatrace" { + dt_env_url = "${var.CN_PROD_ENV_URL}" + dt_api_token = "${var.CN_PROD_API_TOKEN}" +} \ No newline at end of file diff --git a/CN_PROD/problem_notification/SLO_Alerting_Central.tf b/CN_PROD/problem_notification/SLO_Alerting_Central.tf new file mode 100644 index 0000000..1cbb653 --- /dev/null +++ b/CN_PROD/problem_notification/SLO_Alerting_Central.tf @@ -0,0 +1,17 @@ +resource "dynatrace_notification" "SLO_Alerting_Central" { + web_hook { + name = "[TEAMS] SLO_Alerting_Central" + accept_any_certificate = true + active = true + alerting_profile = data.terraform_remote_state.alerting_profiles.outputs.SLO_Alerting_Central_id + notify_event_merges = true + payload = <<-EOT + { + "title":"{ProblemTitle}", + "text":"{ProblemDetailsHTML}", + "themeColor":"EA4300" + } + EOT + url = "https://bmwgroup.webhook.office.com/webhookb2/483edc00-c925-4672-8088-8299a0139fca@ce849bab-cc1c-465b-b62e-18f07c9ac198/IncomingWebhook/c44b5bc7c0094aba8b870dcf12b7e55e/af36b177-c3fb-4707-a2d4-c75dbce454a2" + } +} diff --git a/CN_PROD/problem_notification/__main.tf b/CN_PROD/problem_notification/__main.tf new file mode 100644 index 0000000..78e63a5 --- /dev/null +++ b/CN_PROD/problem_notification/__main.tf @@ -0,0 +1,37 @@ +terraform { + required_providers { + dynatrace = { + version = "1.11.0" + source = "dynatrace-oss/dynatrace" + } + } + + backend "s3" { + bucket = "coco-dynatrace-tfstate" + key = "cnprod/problem_notification/terraform.tfstate" + region = "eu-central-1" + dynamodb_table = "coco-dynatrace-tfstate" + encrypt = true + } + +} + +data "terraform_remote_state" "alerting_profiles" { + backend = "s3" + config = { + bucket = "coco-dynatrace-tfstate" + key = "cnprod/alerting_profiles/terraform.tfstate" + region = "eu-central-1" + encrypt = true + dynamodb_table = "coco-dynatrace-tfstate" + } +} + +variable CN_PROD_ENV_URL {} +variable CN_PROD_API_TOKEN {} + + +provider "dynatrace" { + dt_env_url = "${var.CN_PROD_ENV_URL}" + dt_api_token = "${var.CN_PROD_API_TOKEN}" +} \ No newline at end of file diff --git a/EMEA_PROD/alerting_profiles/SLO_Alerting_Central.tf b/EMEA_PROD/alerting_profiles/SLO_Alerting_Central.tf new file mode 100644 index 0000000..f3981c6 --- /dev/null +++ b/EMEA_PROD/alerting_profiles/SLO_Alerting_Central.tf @@ -0,0 +1,18 @@ +resource "dynatrace_alerting_profile" "SLO_Alerting_Central" { + display_name = "SLO_Alerting_Central" + event_type_filters { + custom_event_filter { + custom_title_filter { + enabled = true + case_insensitive = true + # negate = false + operator = "CONTAINS" + value = "TP_" + } + } + } +} + +output "SLO_Alerting_Central_id" { + value = dynatrace_alerting_profile.SLO_Alerting_Central.id +} diff --git a/EMEA_PROD/alerting_profiles/__main.tf b/EMEA_PROD/alerting_profiles/__main.tf new file mode 100644 index 0000000..fc9e83a --- /dev/null +++ b/EMEA_PROD/alerting_profiles/__main.tf @@ -0,0 +1,26 @@ +terraform { + required_providers { + dynatrace = { + version = "1.11.0" + source = "dynatrace-oss/dynatrace" + } + } + + backend "s3" { + bucket = "coco-dynatrace-tfstate" + key = "euprod/alerting_profiles/terraform.tfstate" + region = "eu-central-1" + dynamodb_table = "coco-dynatrace-tfstate" + encrypt = true + } + +} + +variable EMEA_PROD_ENV_URL {} +variable EMEA_PROD_API_TOKEN {} + + +provider "dynatrace" { + dt_env_url = "${var.EMEA_PROD_ENV_URL}" + dt_api_token = "${var.EMEA_PROD_API_TOKEN}" +} \ No newline at end of file diff --git a/EMEA_PROD/problem_notification/SLO_Alerting_Central.tf b/EMEA_PROD/problem_notification/SLO_Alerting_Central.tf new file mode 100644 index 0000000..1cbb653 --- /dev/null +++ b/EMEA_PROD/problem_notification/SLO_Alerting_Central.tf @@ -0,0 +1,17 @@ +resource "dynatrace_notification" "SLO_Alerting_Central" { + web_hook { + name = "[TEAMS] SLO_Alerting_Central" + accept_any_certificate = true + active = true + alerting_profile = data.terraform_remote_state.alerting_profiles.outputs.SLO_Alerting_Central_id + notify_event_merges = true + payload = <<-EOT + { + "title":"{ProblemTitle}", + "text":"{ProblemDetailsHTML}", + "themeColor":"EA4300" + } + EOT + url = "https://bmwgroup.webhook.office.com/webhookb2/483edc00-c925-4672-8088-8299a0139fca@ce849bab-cc1c-465b-b62e-18f07c9ac198/IncomingWebhook/c44b5bc7c0094aba8b870dcf12b7e55e/af36b177-c3fb-4707-a2d4-c75dbce454a2" + } +} diff --git a/EMEA_PROD/problem_notification/__main.tf b/EMEA_PROD/problem_notification/__main.tf new file mode 100644 index 0000000..17583f8 --- /dev/null +++ b/EMEA_PROD/problem_notification/__main.tf @@ -0,0 +1,37 @@ +terraform { + required_providers { + dynatrace = { + version = "1.11.0" + source = "dynatrace-oss/dynatrace" + } + } + + backend "s3" { + bucket = "coco-dynatrace-tfstate" + key = "euprod/problem_notification/terraform.tfstate" + region = "eu-central-1" + dynamodb_table = "coco-dynatrace-tfstate" + encrypt = true + } + +} + +data "terraform_remote_state" "alerting_profiles" { + backend = "s3" + config = { + bucket = "coco-dynatrace-tfstate" + key = "euprod/alerting_profiles/terraform.tfstate" + region = "eu-central-1" + encrypt = true + dynamodb_table = "coco-dynatrace-tfstate" + } +} + +variable EMEA_PROD_ENV_URL {} +variable EMEA_PROD_API_TOKEN {} + + +provider "dynatrace" { + dt_env_url = "${var.EMEA_PROD_ENV_URL}" + dt_api_token = "${var.EMEA_PROD_API_TOKEN}" +} \ No newline at end of file diff --git a/NA_PROD/alerting_profiles/SLO_Alerting_Central.tf b/NA_PROD/alerting_profiles/SLO_Alerting_Central.tf new file mode 100644 index 0000000..f3981c6 --- /dev/null +++ b/NA_PROD/alerting_profiles/SLO_Alerting_Central.tf @@ -0,0 +1,18 @@ +resource "dynatrace_alerting_profile" "SLO_Alerting_Central" { + display_name = "SLO_Alerting_Central" + event_type_filters { + custom_event_filter { + custom_title_filter { + enabled = true + case_insensitive = true + # negate = false + operator = "CONTAINS" + value = "TP_" + } + } + } +} + +output "SLO_Alerting_Central_id" { + value = dynatrace_alerting_profile.SLO_Alerting_Central.id +} diff --git a/NA_PROD/alerting_profiles/__main.tf b/NA_PROD/alerting_profiles/__main.tf new file mode 100644 index 0000000..2784f36 --- /dev/null +++ b/NA_PROD/alerting_profiles/__main.tf @@ -0,0 +1,26 @@ +terraform { + required_providers { + dynatrace = { + version = "1.11.0" + source = "dynatrace-oss/dynatrace" + } + } + + backend "s3" { + bucket = "coco-dynatrace-tfstate" + key = "naprod/alerting_profiles/terraform.tfstate" + region = "eu-central-1" + dynamodb_table = "coco-dynatrace-tfstate" + encrypt = true + } + +} + +variable NA_PROD_ENV_URL {} +variable NA_PROD_API_TOKEN {} + + +provider "dynatrace" { + dt_env_url = "${var.NA_PROD_ENV_URL}" + dt_api_token = "${var.NA_PROD_API_TOKEN}" +} \ No newline at end of file diff --git a/NA_PROD/problem_notification/SLO_Alerting_Central.tf b/NA_PROD/problem_notification/SLO_Alerting_Central.tf new file mode 100644 index 0000000..1cbb653 --- /dev/null +++ b/NA_PROD/problem_notification/SLO_Alerting_Central.tf @@ -0,0 +1,17 @@ +resource "dynatrace_notification" "SLO_Alerting_Central" { + web_hook { + name = "[TEAMS] SLO_Alerting_Central" + accept_any_certificate = true + active = true + alerting_profile = data.terraform_remote_state.alerting_profiles.outputs.SLO_Alerting_Central_id + notify_event_merges = true + payload = <<-EOT + { + "title":"{ProblemTitle}", + "text":"{ProblemDetailsHTML}", + "themeColor":"EA4300" + } + EOT + url = "https://bmwgroup.webhook.office.com/webhookb2/483edc00-c925-4672-8088-8299a0139fca@ce849bab-cc1c-465b-b62e-18f07c9ac198/IncomingWebhook/c44b5bc7c0094aba8b870dcf12b7e55e/af36b177-c3fb-4707-a2d4-c75dbce454a2" + } +} diff --git a/NA_PROD/problem_notification/__main.tf b/NA_PROD/problem_notification/__main.tf new file mode 100644 index 0000000..810d249 --- /dev/null +++ b/NA_PROD/problem_notification/__main.tf @@ -0,0 +1,37 @@ +terraform { + required_providers { + dynatrace = { + version = "1.11.0" + source = "dynatrace-oss/dynatrace" + } + } + + backend "s3" { + bucket = "coco-dynatrace-tfstate" + key = "naprod/problem_notification/terraform.tfstate" + region = "eu-central-1" + dynamodb_table = "coco-dynatrace-tfstate" + encrypt = true + } + +} + +data "terraform_remote_state" "alerting_profiles" { + backend = "s3" + config = { + bucket = "coco-dynatrace-tfstate" + key = "naprod/alerting_profiles/terraform.tfstate" + region = "eu-central-1" + encrypt = true + dynamodb_table = "coco-dynatrace-tfstate" + } +} + +variable NA_PROD_ENV_URL {} +variable NA_PROD_API_TOKEN {} + + +provider "dynatrace" { + dt_env_url = "${var.NA_PROD_ENV_URL}" + dt_api_token = "${var.NA_PROD_API_TOKEN}" +} \ No newline at end of file