diff --git a/CN_PREPROD/.gitkeep b/CN_PREPROD/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/CN_PREPROD/main.tf b/CN_PREPROD/main.tf deleted file mode 100644 index 5c895aed..00000000 --- a/CN_PREPROD/main.tf +++ /dev/null @@ -1,12 +0,0 @@ -module "management_zone" { - source = "./management_zone" -} - -module "alerting" { - source = "./alerting" - depends_on = [module.management_zone] -} -module "dashboard" { - source = "./dashboard" - depends_on = [module.management_zone] -} diff --git a/CN_PREPROD/providers.tf b/CN_PREPROD/providers.tf deleted file mode 100644 index 6da2e8a8..00000000 --- a/CN_PREPROD/providers.tf +++ /dev/null @@ -1,20 +0,0 @@ -terraform { - required_providers { - dynatrace = { - version = "1.14.1" - source = "dynatrace-oss/dynatrace" - } - } -} -variable "DYNATRACE_CNPREPROD_ENV_URL" { - type = string - description = "URL of Dynatrace environment" -} -variable "DYNATRACE_CNPREPROD_API_TOKEN" { - type = string - description = "API token for Dynatrace environment" -} -provider "dynatrace" { - dt_env_url = "${var.DYNATRACE_CNPREPROD_ENV_URL}" - dt_api_token = "${var.DYNATRACE_CNPREPROD_API_TOKEN}" -} \ No newline at end of file diff --git a/CN_PROD/.gitkeep b/CN_PROD/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/CN_PROD/main.tf b/CN_PROD/main.tf deleted file mode 100644 index 5c895aed..00000000 --- a/CN_PROD/main.tf +++ /dev/null @@ -1,12 +0,0 @@ -module "management_zone" { - source = "./management_zone" -} - -module "alerting" { - source = "./alerting" - depends_on = [module.management_zone] -} -module "dashboard" { - source = "./dashboard" - depends_on = [module.management_zone] -} diff --git a/CN_PROD/providers.tf b/CN_PROD/providers.tf deleted file mode 100644 index e3df0f99..00000000 --- a/CN_PROD/providers.tf +++ /dev/null @@ -1,20 +0,0 @@ -terraform { - required_providers { - dynatrace = { - version = "1.14.1" - source = "dynatrace-oss/dynatrace" - } - } -} -variable "DYNATRACE_CNPROD_ENV_URL" { - type = string - description = "URL of Dynatrace environment" -} -variable "DYNATRACE_CNPROD_API_TOKEN" { - type = string - description = "API token for Dynatrace environment" -} -provider "dynatrace" { - dt_env_url = "${var.DYNATRACE_CNPROD_ENV_URL}" - dt_api_token = "${var.DYNATRACE_CNPROD_API_TOKEN}" -} \ No newline at end of file diff --git a/EMEA_PREPROD/.gitkeep b/EMEA_PREPROD/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/EMEA_PREPROD/main.tf b/EMEA_PREPROD/main.tf deleted file mode 100644 index 5c895aed..00000000 --- a/EMEA_PREPROD/main.tf +++ /dev/null @@ -1,12 +0,0 @@ -module "management_zone" { - source = "./management_zone" -} - -module "alerting" { - source = "./alerting" - depends_on = [module.management_zone] -} -module "dashboard" { - source = "./dashboard" - depends_on = [module.management_zone] -} diff --git a/EMEA_PREPROD/providers.tf b/EMEA_PREPROD/providers.tf deleted file mode 100644 index a528dde7..00000000 --- a/EMEA_PREPROD/providers.tf +++ /dev/null @@ -1,20 +0,0 @@ -terraform { - required_providers { - dynatrace = { - version = "1.14.1" - source = "dynatrace-oss/dynatrace" - } - } -} -variable "DYNATRACE_EMEAPREPROD_ENV_URL" { - type = string - description = "URL of Dynatrace environment" -} -variable "DYNATRACE_EMEAPREPROD_API_TOKEN" { - type = string - description = "API token for Dynatrace environment" -} -provider "dynatrace" { - dt_env_url = "${var.DYNATRACE_EMEAPREPROD_ENV_URL}" - dt_api_token = "${var.DYNATRACE_EMEAPREPROD_API_TOKEN}" -} \ No newline at end of file diff --git a/EMEA_PROD/.gitkeep b/EMEA_PROD/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/EMEA_PROD/main.tf b/EMEA_PROD/main.tf deleted file mode 100644 index 5c895aed..00000000 --- a/EMEA_PROD/main.tf +++ /dev/null @@ -1,12 +0,0 @@ -module "management_zone" { - source = "./management_zone" -} - -module "alerting" { - source = "./alerting" - depends_on = [module.management_zone] -} -module "dashboard" { - source = "./dashboard" - depends_on = [module.management_zone] -} diff --git a/EMEA_PROD/providers.tf b/EMEA_PROD/providers.tf deleted file mode 100644 index 5599c207..00000000 --- a/EMEA_PROD/providers.tf +++ /dev/null @@ -1,20 +0,0 @@ -terraform { - required_providers { - dynatrace = { - version = "1.14.1" - source = "dynatrace-oss/dynatrace" - } - } -} -variable "DYNATRACE_EMEAPROD_ENV_URL" { - type = string - description = "URL of Dynatrace environment" -} -variable "DYNATRACE_EMEAPROD_API_TOKEN" { - type = string - description = "API token for Dynatrace environment" -} -provider "dynatrace" { - dt_env_url = "${var.DYNATRACE_EMEAPROD_ENV_URL}" - dt_api_token = "${var.DYNATRACE_EMEAPROD_API_TOKEN}" -} \ No newline at end of file diff --git a/NA_PREPROD/.gitkeep b/NA_PREPROD/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/NA_PREPROD/main.tf b/NA_PREPROD/main.tf deleted file mode 100644 index 5c895aed..00000000 --- a/NA_PREPROD/main.tf +++ /dev/null @@ -1,12 +0,0 @@ -module "management_zone" { - source = "./management_zone" -} - -module "alerting" { - source = "./alerting" - depends_on = [module.management_zone] -} -module "dashboard" { - source = "./dashboard" - depends_on = [module.management_zone] -} diff --git a/NA_PREPROD/providers.tf b/NA_PREPROD/providers.tf deleted file mode 100644 index 618d1e0f..00000000 --- a/NA_PREPROD/providers.tf +++ /dev/null @@ -1,20 +0,0 @@ -terraform { - required_providers { - dynatrace = { - version = "1.14.1" - source = "dynatrace-oss/dynatrace" - } - } -} -variable "DYNATRACE_NAPREPROD_ENV_URL" { - type = string - description = "URL of Dynatrace environment" -} -variable "DYNATRACE_NAPREPROD_API_TOKEN" { - type = string - description = "API token for Dynatrace environment" -} -provider "dynatrace" { - dt_env_url = "${var.DYNATRACE_NAPREPROD_ENV_URL}" - dt_api_token = "${var.DYNATRACE_NAPREPROD_API_TOKEN}" -} \ No newline at end of file diff --git a/NA_PROD/.gitkeep b/NA_PROD/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/NA_PROD/main.tf b/NA_PROD/main.tf deleted file mode 100644 index 5c895aed..00000000 --- a/NA_PROD/main.tf +++ /dev/null @@ -1,12 +0,0 @@ -module "management_zone" { - source = "./management_zone" -} - -module "alerting" { - source = "./alerting" - depends_on = [module.management_zone] -} -module "dashboard" { - source = "./dashboard" - depends_on = [module.management_zone] -} diff --git a/NA_PROD/providers.tf b/NA_PROD/providers.tf deleted file mode 100644 index ae9b0dab..00000000 --- a/NA_PROD/providers.tf +++ /dev/null @@ -1,20 +0,0 @@ -terraform { - required_providers { - dynatrace = { - version = "1.14.1" - source = "dynatrace-oss/dynatrace" - } - } -} -variable "DYNATRACE_NAPROD_ENV_URL" { - type = string - description = "URL of Dynatrace environment" -} -variable "DYNATRACE_NAPROD_API_TOKEN" { - type = string - description = "API token for Dynatrace environment" -} -provider "dynatrace" { - dt_env_url = "${var.DYNATRACE_NAPROD_ENV_URL}" - dt_api_token = "${var.DYNATRACE_NAPROD_API_TOKEN}" -} \ No newline at end of file diff --git a/_templates/_template_alerting_profile.tf b/_templates/_template_alerting_profile.tf index e69de29b..2c08a7e7 100644 --- a/_templates/_template_alerting_profile.tf +++ b/_templates/_template_alerting_profile.tf @@ -0,0 +1,36 @@ +resource "dynatrace_alerting" "_" { + name = " " + management_zone = data.dynatrace_management_zone..id + rules { + rule { + delay_in_minutes = 0 + include_mode = "INCLUDE_ALL" + severity_level = "AVAILABILITY" + tags = [ "Environment:" ] + } + rule { + delay_in_minutes = 10 + include_mode = "INCLUDE_ALL" + severity_level = "CUSTOM_ALERT" + tags = [ "Environment:" ] + } + rule { + delay_in_minutes = 10 + include_mode = "INCLUDE_ALL" + severity_level = "ERRORS" + tags = [ "Environment:" ] + } + rule { + delay_in_minutes = 30 + include_mode = "INCLUDE_ALL" + severity_level = "PERFORMANCE" + tags = [ "Environment:" ] + } + rule { + delay_in_minutes = 30 + include_mode = "INCLUDE_ALL" + severity_level = "RESOURCE_CONTENTION" + tags = [ "Environment:" ] + } + } +} diff --git a/_templates/_template_dashboard.tf b/_templates/_template_dashboard.tf index e69de29b..4a3246c7 100644 --- a/_templates/_template_dashboard.tf +++ b/_templates/_template_dashboard.tf @@ -0,0 +1,328 @@ +resource "dynatrace_dashboard" "_" { + dashboard_metadata { + name = " " + owner = "Ignacio.Goldman@partner.bmwgroup.com" + preset = true + shared = true + tags = [ "" ] + filter { + timeframe = "-24h to now" + } + } + tile { + name = "Custom chart" + configured = true + tile_type = "CUSTOM_CHARTING" + bounds { + height = 304 + left = 38 + top = 228 + width = 1064 + } + filter { + management_zone { + name = "" + id = data.dynatrace_management_zone..id + } + } + filter_config { + type = "MIXED" + custom_name = "Failure rate (HTTP 4xx/5xx errors)" + default_name = "Custom chart" + chart_config { + type = "TIMESERIES" + legend = true + result_metadata { + config { + custom_color = "#ff0000" + key = "nullbuiltin:service.errors.fivexx.rate|AVG|TOTAL|BAR|SERVICE" + last_modified = 1617956393463 + } + config { + custom_color = "#fff29a" + key = "nullbuiltin:service.errors.fourxx.rate|AVG|TOTAL|BAR|SERVICE" + last_modified = 1617956441725 + } + } + series { + type = "BAR" + aggregation = "AVG" + aggregation_rate = "TOTAL" + entity_type = "SERVICE" + metric = "builtin:service.errors.fourxx.rate" + # sort_ascending = false + # sort_column = false + } + series { + type = "BAR" + aggregation = "AVG" + aggregation_rate = "TOTAL" + entity_type = "SERVICE" + metric = "builtin:service.errors.fivexx.rate" + # sort_ascending = false + sort_column = true + } + } + filters { + filter { + entity_type = "SERVICE" + match { + key = "AUTO_TAGS" + values = [ "Environment:" ] + } + } + } + } + } + tile { + name = "Problems" + configured = true + tile_type = "OPEN_PROBLEMS" + bounds { + height = 152 + left = 950 + top = 38 + width = 152 + } + filter { + management_zone { + name = "" + id = data.dynatrace_management_zone..id + } + } + } + tile { + name = "Overall Health" + configured = true + tile_type = "HEADER" + bounds { + height = 38 + left = 38 + top = 0 + width = 1064 + } + filter { + management_zone { + name = "" + id = data.dynatrace_management_zone..id + } + } + } + tile { + name = "Markdown" + configured = true + markdown =<<-EOT + --- + + EOT + tile_type = "MARKDOWN" + bounds { + height = 38 + left = 38 + top = 532 + width = 1064 + } + } + tile { + name = "Custom chart" + configured = true + tile_type = "CUSTOM_CHARTING" + bounds { + height = 304 + left = 38 + top = 570 + width = 1064 + } + filter { + management_zone { + name = "" + id = data.dynatrace_management_zone..id + } + } + filter_config { + type = "MIXED" + custom_name = "Response time, Request Count and Number of Errors" + default_name = "Custom chart" + chart_config { + type = "TIMESERIES" + legend = true + result_metadata { + config { + custom_color = "#008cdb" + key = "nullbuiltin:service.requestCount.total|NONE|TOTAL|BAR|SERVICE" + last_modified = 1595275720776 + } + config { + custom_color = "#b4e5f9" + key = "nullbuiltin:service.response.time|AVG|TOTAL|LINE|SERVICE" + last_modified = 1595275686773 + } + config { + custom_color = "#ef651f" + key = "nullbuiltin:service.errors.total.count|NONE|TOTAL|BAR|SERVICE" + last_modified = 1595275955999 + } + } + series { + type = "LINE" + aggregation = "AVG" + aggregation_rate = "TOTAL" + entity_type = "SERVICE" + metric = "builtin:service.response.time" + # sort_ascending = false + # sort_column = false + } + series { + type = "BAR" + aggregation = "NONE" + aggregation_rate = "TOTAL" + entity_type = "SERVICE" + metric = "builtin:service.requestCount.total" + # sort_ascending = false + # sort_column = false + } + series { + type = "BAR" + aggregation = "NONE" + aggregation_rate = "TOTAL" + entity_type = "SERVICE" + metric = "builtin:service.errors.total.count" + # sort_ascending = false + sort_column = true + } + } + filters { + filter { + entity_type = "SERVICE" + match { + key = "AUTO_TAGS" + values = [ "Environment:" ] + } + } + } + } + } + tile { + name = "Markdown" + configured = true + markdown =<<-EOT + --- + + EOT + tile_type = "MARKDOWN" + bounds { + height = 38 + left = 38 + top = 190 + width = 1064 + } + } + tile { + name = "" + chart_visible = true + configured = true + tile_type = "DATABASES_OVERVIEW" + bounds { + height = 152 + left = 646 + top = 38 + width = 190 + } + filter { + management_zone { + name = "" + id = data.dynatrace_management_zone..id + } + } + filter_config { + type = "DATABASE" + custom_name = "Databases" + default_name = "Databases" + chart_config { + type = "TIMESERIES" + legend = true + } + filters { + filter { + entity_type = "DATABASE" + match { + key = "AUTO_TAGS" + values = [ "Environment:" ] + } + } + } + } + } + tile { + name = "" + chart_visible = true + configured = true + tile_type = "SERVICES" + bounds { + height = 152 + left = 342 + top = 38 + width = 190 + } + filter { + management_zone { + name = "" + id = data.dynatrace_management_zone..id + } + } + filter_config { + type = "SERVICE" + custom_name = "Services" + default_name = "Services" + chart_config { + type = "TIMESERIES" + legend = true + } + filters { + filter { + entity_type = "SERVICE" + match { + key = "AUTO_TAGS" + values = [ "Environment:" ] + } + } + } + } + } + tile { + name = "" + chart_visible = true + configured = true + tile_type = "HOSTS" + bounds { + height = 152 + left = 38 + top = 38 + width = 190 + } + filter { + management_zone { + name = "" + id = data.dynatrace_management_zone..id + } + } + filter_config { + type = "HOST" + custom_name = "Hosts" + default_name = "Hosts" + chart_config { + type = "TIMESERIES" + legend = true + } + filters { + filter { + entity_type = "HOST" + match { + key = "AUTO_TAGS" + values = [ "Environment:" ] + } + } + } + } + } +} diff --git a/_templates/_template_management_zone.tf b/_templates/_template_management_zone.tf index e69de29b..97a05029 100644 --- a/_templates/_template_management_zone.tf +++ b/_templates/_template_management_zone.tf @@ -0,0 +1,19 @@ +resource "dynatrace_management_zone" "" { + name = "" + entity_selector_based_rule { + enabled = true + selector = "type(PROCESS_GROUP_INSTANCE),tag(\"compass-id:\")" + } + entity_selector_based_rule { + enabled = true + selector = "type(HOST),tag(\"compass-id:\")" + } + entity_selector_based_rule { + enabled = true + selector = "type(Service),tag(\"compass-id:\")" + } + entity_selector_based_rule { + enabled = true + selector = "type(SERVICE),databaseName.exists(),toRelationship.calls(type(SERVICE),tag(\"compass-id:\"))" + } +}