From fb47b4fadb2d5c56fd809fdf11b609d3f6ff482f Mon Sep 17 00:00:00 2001 From: Patryk Gudalewicz Date: Wed, 1 Mar 2023 18:56:33 +0100 Subject: [PATCH] "Migrating from Monaco to Terraform for management zone: CD_CoCo-Health-Monitor" --- .../alerting/cd_coco-health-monitor_int.tf | 38 ++ .../dashboard/cd_coco-health-monitor_int.tf | 360 ++++++++++++++++++ .../dashboard/cd_coco-health-monitor_test.tf | 360 ++++++++++++++++++ .../management_zone/cd_coco-health-monitor.tf | 52 +++ 4 files changed, 810 insertions(+) create mode 100644 EMEA_PREPROD/alerting/cd_coco-health-monitor_int.tf create mode 100644 EMEA_PREPROD/dashboard/cd_coco-health-monitor_int.tf create mode 100644 EMEA_PREPROD/dashboard/cd_coco-health-monitor_test.tf create mode 100644 EMEA_PREPROD/management_zone/cd_coco-health-monitor.tf diff --git a/EMEA_PREPROD/alerting/cd_coco-health-monitor_int.tf b/EMEA_PREPROD/alerting/cd_coco-health-monitor_int.tf new file mode 100644 index 00000000..b04ffabd --- /dev/null +++ b/EMEA_PREPROD/alerting/cd_coco-health-monitor_int.tf @@ -0,0 +1,38 @@ +# DEFINE dynatrace_alerting.CD_CoCo-Health-Monitor_INT.id = vu9U3hXa3q0AAAABABhidWlsdGluOmFsZXJ0aW5nLnByb2ZpbGUABnRlbmFudAAGdGVuYW50ACQxNmRiN2QyMS00NThmLTM3YTAtODRhZi1iZTNjZmI2M2IyNjm-71TeFdrerQ +data "dynatrace_management_zone" "CD_CoCo-Health-Monitor_INT"{ name="CD_CoCo-Health-Monitor" } +resource "dynatrace_alerting" "CD_CoCo-Health-Monitor_INT" { + name = "CD_CoCo-Health-Monitor INT" + management_zone = data.dynatrace_management_zone.CD_CoCo-Health-Monitor_INT.id + rules { + rule { + delay_in_minutes = 0 + include_mode = "INCLUDE_ALL" + severity_level = "AVAILABILITY" + tags = [ "Environment:INT" ] + } + rule { + delay_in_minutes = 10 + include_mode = "INCLUDE_ALL" + severity_level = "CUSTOM_ALERT" + tags = [ "Environment:INT" ] + } + rule { + delay_in_minutes = 10 + include_mode = "INCLUDE_ALL" + severity_level = "ERRORS" + tags = [ "Environment:INT" ] + } + rule { + delay_in_minutes = 30 + include_mode = "INCLUDE_ALL" + severity_level = "PERFORMANCE" + tags = [ "Environment:INT" ] + } + rule { + delay_in_minutes = 30 + include_mode = "INCLUDE_ALL" + severity_level = "RESOURCE_CONTENTION" + tags = [ "Environment:INT" ] + } + } +} \ No newline at end of file diff --git a/EMEA_PREPROD/dashboard/cd_coco-health-monitor_int.tf b/EMEA_PREPROD/dashboard/cd_coco-health-monitor_int.tf new file mode 100644 index 00000000..70c1828a --- /dev/null +++ b/EMEA_PREPROD/dashboard/cd_coco-health-monitor_int.tf @@ -0,0 +1,360 @@ +# DEFINE dynatrace_dashboard.CD_CoCo-Health-Monitor_INT.id = 0fa7c502-98fc-4583-a12a-5939c7727f3a +data "dynatrace_management_zone" "CD_CoCo-Health-Monitor_INT"{ name="CD_CoCo-Health-Monitor" } +resource "dynatrace_dashboard" "CD_CoCo-Health-Monitor_INT" { + dashboard_metadata { + name = "CD_CoCo-Health-Monitor INT" + owner = "katharina.kiechle@bmw.de" + preset = true + shared = true + tags = [ "CD_CoCo-Health-Monitor" ] + unknowns = jsonencode({ + "popularity": 1 + }) + filter { + timeframe = "-24h to now" + } + } + tile { + name = "Custom chart" + configured = true + tile_type = "CUSTOM_CHARTING" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 304 + left = 38 + top = 228 + width = 1064 + } + filter { + management_zone { + name = "CD_CoCo-Health-Monitor" + id = data.dynatrace_management_zone.CD_CoCo-Health-Monitor_INT.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:INT" ] + } + } + } + } + } + tile { + name = "Problems" + configured = true + tile_type = "OPEN_PROBLEMS" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 152 + left = 950 + top = 38 + width = 152 + } + filter { + management_zone { + name = "CD_CoCo-Health-Monitor" + id = data.dynatrace_management_zone.CD_CoCo-Health-Monitor_INT.id + } + } + } + tile { + name = "Overall Health" + configured = true + tile_type = "HEADER" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 38 + left = 38 + top = 0 + width = 1064 + } + filter { + management_zone { + name = "CD_CoCo-Health-Monitor" + id = data.dynatrace_management_zone.CD_CoCo-Health-Monitor_INT.id + } + } + } + tile { + name = "Markdown" + configured = true + markdown =<<-EOT + --- + + EOT + tile_type = "MARKDOWN" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 38 + left = 38 + top = 532 + width = 1064 + } + } + tile { + name = "Custom chart" + configured = true + tile_type = "CUSTOM_CHARTING" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 304 + left = 38 + top = 570 + width = 1064 + } + filter { + management_zone { + name = "CD_CoCo-Health-Monitor" + id = data.dynatrace_management_zone.CD_CoCo-Health-Monitor_INT.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:INT" ] + } + } + } + } + } + tile { + name = "Markdown" + configured = true + markdown =<<-EOT + --- + + EOT + tile_type = "MARKDOWN" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 38 + left = 38 + top = 190 + width = 1064 + } + } + tile { + name = "" + chart_visible = true + configured = true + tile_type = "DATABASES_OVERVIEW" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 152 + left = 646 + top = 38 + width = 190 + } + filter { + management_zone { + name = "CD_CoCo-Health-Monitor" + id = data.dynatrace_management_zone.CD_CoCo-Health-Monitor_INT.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:INT" ] + } + } + } + } + } + tile { + name = "" + chart_visible = true + configured = true + tile_type = "SERVICES" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 152 + left = 342 + top = 38 + width = 190 + } + filter { + management_zone { + name = "CD_CoCo-Health-Monitor" + id = data.dynatrace_management_zone.CD_CoCo-Health-Monitor_INT.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:INT" ] + } + } + } + } + } + tile { + name = "" + chart_visible = true + configured = true + tile_type = "HOSTS" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 152 + left = 38 + top = 38 + width = 190 + } + filter { + management_zone { + name = "CD_CoCo-Health-Monitor" + id = data.dynatrace_management_zone.CD_CoCo-Health-Monitor_INT.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:INT" ] + } + } + } + } + } +} \ No newline at end of file diff --git a/EMEA_PREPROD/dashboard/cd_coco-health-monitor_test.tf b/EMEA_PREPROD/dashboard/cd_coco-health-monitor_test.tf new file mode 100644 index 00000000..4ee92989 --- /dev/null +++ b/EMEA_PREPROD/dashboard/cd_coco-health-monitor_test.tf @@ -0,0 +1,360 @@ +# DEFINE dynatrace_dashboard.CD_CoCo-Health-Monitor_TEST.id = 56f98352-d15b-4b6b-b6b4-254f64ee06bf +data "dynatrace_management_zone" "CD_CoCo-Health-Monitor_TEST"{ name="CD_CoCo-Health-Monitor" } +resource "dynatrace_dashboard" "CD_CoCo-Health-Monitor_TEST" { + dashboard_metadata { + name = "CD_CoCo-Health-Monitor TEST" + owner = "katharina.kiechle@bmw.de" + preset = true + shared = true + tags = [ "CD_CoCo-Health-Monitor" ] + unknowns = jsonencode({ + "popularity": 1 + }) + filter { + timeframe = "-24h to now" + } + } + tile { + name = "Custom chart" + configured = true + tile_type = "CUSTOM_CHARTING" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 304 + left = 38 + top = 228 + width = 1064 + } + filter { + management_zone { + name = "CD_CoCo-Health-Monitor" + id = data.dynatrace_management_zone.CD_CoCo-Health-Monitor_TEST.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:TEST" ] + } + } + } + } + } + tile { + name = "Problems" + configured = true + tile_type = "OPEN_PROBLEMS" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 152 + left = 950 + top = 38 + width = 152 + } + filter { + management_zone { + name = "CD_CoCo-Health-Monitor" + id = data.dynatrace_management_zone.CD_CoCo-Health-Monitor_TEST.id + } + } + } + tile { + name = "Overall Health" + configured = true + tile_type = "HEADER" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 38 + left = 38 + top = 0 + width = 1064 + } + filter { + management_zone { + name = "CD_CoCo-Health-Monitor" + id = data.dynatrace_management_zone.CD_CoCo-Health-Monitor_TEST.id + } + } + } + tile { + name = "Markdown" + configured = true + markdown =<<-EOT + --- + + EOT + tile_type = "MARKDOWN" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 38 + left = 38 + top = 532 + width = 1064 + } + } + tile { + name = "Custom chart" + configured = true + tile_type = "CUSTOM_CHARTING" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 304 + left = 38 + top = 570 + width = 1064 + } + filter { + management_zone { + name = "CD_CoCo-Health-Monitor" + id = data.dynatrace_management_zone.CD_CoCo-Health-Monitor_TEST.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:TEST" ] + } + } + } + } + } + tile { + name = "Markdown" + configured = true + markdown =<<-EOT + --- + + EOT + tile_type = "MARKDOWN" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 38 + left = 38 + top = 190 + width = 1064 + } + } + tile { + name = "" + chart_visible = true + configured = true + tile_type = "DATABASES_OVERVIEW" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 152 + left = 646 + top = 38 + width = 190 + } + filter { + management_zone { + name = "CD_CoCo-Health-Monitor" + id = data.dynatrace_management_zone.CD_CoCo-Health-Monitor_TEST.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:TEST" ] + } + } + } + } + } + tile { + name = "" + chart_visible = true + configured = true + tile_type = "SERVICES" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 152 + left = 342 + top = 38 + width = 190 + } + filter { + management_zone { + name = "CD_CoCo-Health-Monitor" + id = data.dynatrace_management_zone.CD_CoCo-Health-Monitor_TEST.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:TEST" ] + } + } + } + } + } + tile { + name = "" + chart_visible = true + configured = true + tile_type = "HOSTS" + unknowns = jsonencode({ + "isAutoRefreshDisabled": false + }) + bounds { + height = 152 + left = 38 + top = 38 + width = 190 + } + filter { + management_zone { + name = "CD_CoCo-Health-Monitor" + id = data.dynatrace_management_zone.CD_CoCo-Health-Monitor_TEST.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:TEST" ] + } + } + } + } + } +} \ No newline at end of file diff --git a/EMEA_PREPROD/management_zone/cd_coco-health-monitor.tf b/EMEA_PREPROD/management_zone/cd_coco-health-monitor.tf new file mode 100644 index 00000000..e2d00992 --- /dev/null +++ b/EMEA_PREPROD/management_zone/cd_coco-health-monitor.tf @@ -0,0 +1,52 @@ +# DEFINE dynatrace_management_zone.CD_CoCo-Health-Monitor.id = -6590700131325037286 +resource "dynatrace_management_zone" "CD_CoCo-Health-Monitor" { + name = "CD_CoCo-Health-Monitor" + entity_selector_based_rule { + enabled = true + selector = "type(SERVICE),databaseName.exists(),toRelationship.calls(type(SERVICE),tag(\"compass-id:coco-hm\"))" + } + entity_selector_based_rule { + enabled = true + selector = "type(HOST),tag(\"compass-id:coco-hm\")" + } + entity_selector_based_rule { + enabled = true + selector = "type(PROCESS_GROUP_INSTANCE),tag(\"compass-id:coco-hm\")" + } + entity_selector_based_rule { + enabled = true + selector = "type(Service),tag(\"compass-id:coco-hm\")" + } + rules { + type = "WEB_APPLICATION" + enabled = true + conditions { + key { + type = "STATIC" + attribute = "WEB_APPLICATION_NAME" + } + string { + case_sensitive = true + # negate = false + operator = "EQUALS" + value = "CoCo Health Monitor - EMEA - INT" + } + } + } + rules { + type = "WEB_APPLICATION" + enabled = true + conditions { + key { + type = "STATIC" + attribute = "WEB_APPLICATION_NAME" + } + string { + case_sensitive = true + # negate = false + operator = "EQUALS" + value = "CoCo Health Monitor - EMEA - TEST" + } + } + } +}