From 41309d696eee341bb46eaf531dbaa01e844f06c6 Mon Sep 17 00:00:00 2001 From: Patryk Gudalewicz Date: Wed, 1 Mar 2023 18:33:03 +0100 Subject: [PATCH] "Migrating from Monaco to Terraform for management zone: CD_AppD_Android" --- CN_PREPROD/alerting/cd_appd_android_int.tf | 38 ++ CN_PREPROD/dashboard/cd_appd_android_int.tf | 330 ++++++++++++++++++ CN_PREPROD/dashboard/cd_appd_android_test.tf | 330 ++++++++++++++++++ CN_PREPROD/management_zone/cd_appd_android.tf | 28 ++ 4 files changed, 726 insertions(+) create mode 100644 CN_PREPROD/alerting/cd_appd_android_int.tf create mode 100644 CN_PREPROD/dashboard/cd_appd_android_int.tf create mode 100644 CN_PREPROD/dashboard/cd_appd_android_test.tf create mode 100644 CN_PREPROD/management_zone/cd_appd_android.tf diff --git a/CN_PREPROD/alerting/cd_appd_android_int.tf b/CN_PREPROD/alerting/cd_appd_android_int.tf new file mode 100644 index 00000000..3ab6f06c --- /dev/null +++ b/CN_PREPROD/alerting/cd_appd_android_int.tf @@ -0,0 +1,38 @@ +# DEFINE dynatrace_alerting.CD_AppD_Android_INT.id = vu9U3hXa3q0AAAABABhidWlsdGluOmFsZXJ0aW5nLnByb2ZpbGUABnRlbmFudAAGdGVuYW50ACQyNzY2MWFmYi05MzQ0LTM3YjQtODgxYy1kNDUzMmZhM2IwMDW-71TeFdrerQ +data "dynatrace_management_zone" "CD_AppD_Android_INT"{ name="CD_AppD_Android" } +resource "dynatrace_alerting" "CD_AppD_Android_INT" { + name = "CD_AppD_Android INT" + management_zone = data.dynatrace_management_zone.CD_AppD_Android_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/CN_PREPROD/dashboard/cd_appd_android_int.tf b/CN_PREPROD/dashboard/cd_appd_android_int.tf new file mode 100644 index 00000000..4c5e6675 --- /dev/null +++ b/CN_PREPROD/dashboard/cd_appd_android_int.tf @@ -0,0 +1,330 @@ +# DEFINE dynatrace_dashboard.CD_AppD_Android_INT.id = 9cfd61fa-c37b-4a35-bcdf-b0caa468a8ea +data "dynatrace_management_zone" "CD_AppD_Android_INT"{ name="CD_AppD_Android" } +resource "dynatrace_dashboard" "CD_AppD_Android_INT" { + dashboard_metadata { + name = "CD_AppD_Android INT" + owner = "Ignacio.Goldman@partner.bmwgroup.com" + preset = true + shared = true + tags = [ "CD_AppD_Android" ] + 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 = "CD_AppD_Android" + id = data.dynatrace_management_zone.CD_AppD_Android_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" + bounds { + height = 152 + left = 950 + top = 38 + width = 152 + } + filter { + management_zone { + name = "CD_AppD_Android" + id = data.dynatrace_management_zone.CD_AppD_Android_INT.id + } + } + } + tile { + name = "Overall Health" + configured = true + tile_type = "HEADER" + bounds { + height = 38 + left = 38 + top = 0 + width = 1064 + } + filter { + management_zone { + name = "CD_AppD_Android" + id = data.dynatrace_management_zone.CD_AppD_Android_INT.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 = "CD_AppD_Android" + id = data.dynatrace_management_zone.CD_AppD_Android_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" + 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 = "CD_AppD_Android" + id = data.dynatrace_management_zone.CD_AppD_Android_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" + bounds { + height = 152 + left = 342 + top = 38 + width = 190 + } + filter { + management_zone { + name = "CD_AppD_Android" + id = data.dynatrace_management_zone.CD_AppD_Android_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" + bounds { + height = 152 + left = 38 + top = 38 + width = 190 + } + filter { + management_zone { + name = "CD_AppD_Android" + id = data.dynatrace_management_zone.CD_AppD_Android_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/CN_PREPROD/dashboard/cd_appd_android_test.tf b/CN_PREPROD/dashboard/cd_appd_android_test.tf new file mode 100644 index 00000000..9809a25e --- /dev/null +++ b/CN_PREPROD/dashboard/cd_appd_android_test.tf @@ -0,0 +1,330 @@ +# DEFINE dynatrace_dashboard.CD_AppD_Android_TEST.id = 96403ce4-2015-49f5-85d5-d4025f6c24cc +data "dynatrace_management_zone" "CD_AppD_Android_TEST"{ name="CD_AppD_Android" } +resource "dynatrace_dashboard" "CD_AppD_Android_TEST" { + dashboard_metadata { + name = "CD_AppD_Android TEST" + owner = "Ignacio.Goldman@partner.bmwgroup.com" + preset = true + shared = true + tags = [ "CD_AppD_Android" ] + 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 = "CD_AppD_Android" + id = data.dynatrace_management_zone.CD_AppD_Android_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" + bounds { + height = 152 + left = 950 + top = 38 + width = 152 + } + filter { + management_zone { + name = "CD_AppD_Android" + id = data.dynatrace_management_zone.CD_AppD_Android_TEST.id + } + } + } + tile { + name = "Overall Health" + configured = true + tile_type = "HEADER" + bounds { + height = 38 + left = 38 + top = 0 + width = 1064 + } + filter { + management_zone { + name = "CD_AppD_Android" + id = data.dynatrace_management_zone.CD_AppD_Android_TEST.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 = "CD_AppD_Android" + id = data.dynatrace_management_zone.CD_AppD_Android_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" + 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 = "CD_AppD_Android" + id = data.dynatrace_management_zone.CD_AppD_Android_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" + bounds { + height = 152 + left = 342 + top = 38 + width = 190 + } + filter { + management_zone { + name = "CD_AppD_Android" + id = data.dynatrace_management_zone.CD_AppD_Android_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" + bounds { + height = 152 + left = 38 + top = 38 + width = 190 + } + filter { + management_zone { + name = "CD_AppD_Android" + id = data.dynatrace_management_zone.CD_AppD_Android_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/CN_PREPROD/management_zone/cd_appd_android.tf b/CN_PREPROD/management_zone/cd_appd_android.tf new file mode 100644 index 00000000..359ea1f1 --- /dev/null +++ b/CN_PREPROD/management_zone/cd_appd_android.tf @@ -0,0 +1,28 @@ +# DEFINE dynatrace_management_zone.CD_AppD_Android.id = -1808521838228381111 +resource "dynatrace_management_zone" "CD_AppD_Android" { + name = "CD_AppD_Android" + entity_selector_based_rule { + enabled = true + selector =<<-EOT + type(Service),tag("app-id:APP-18165"),fromRelationships.runsOn(type(PROCESS_GROUP),entityName.equals("android-app-distribution")) + EOT + } + entity_selector_based_rule { + enabled = true + selector =<<-EOT + type(SERVICE),databaseName.exists(),toRelationship.calls(type(SERVICE),tag("app-id:APP-18165"),fromRelationships.runsOn(type(PROCESS_GROUP),entityName.equals("android-app-distribution"))) + EOT + } + entity_selector_based_rule { + enabled = true + selector =<<-EOT + type(PROCESS_GROUP_INSTANCE),tag("app-id:APP-18165"),fromRelationships.isInstanceOf(type(PROCESS_GROUP),entityName.equals("android-app-distribution")) + EOT + } + entity_selector_based_rule { + enabled = true + selector =<<-EOT + type(HOST),toRelationships.isProcessOf(type(PROCESS_GROUP_INSTANCE),tag("app-id:APP-18165"),fromRelationships.isInstanceOf(type(PROCESS_GROUP),entityName.equals("android-app-distribution"))) + EOT + } +}