adding tag_filters to alerting profiles

M_sloFix
rforstner 2021-12-22 10:50:18 +01:00
parent b7aa1833d5
commit d7a3d180a9
3 changed files with 71 additions and 9 deletions

View File

@ -9,3 +9,5 @@ variable delay_ERROR {default = 0}
variable delay_MONITORING_UNAVAILABLE {default = 0}
variable delay_PERFORMANCE {default = 0}
variable delay_RESOURCE_CONTENTION {default = 0}
variable tag_filters {}
variable include_mode {default = "NONE"}

View File

@ -15,7 +15,15 @@ resource dynatrace_alerting_profile main {
delay_in_minutes = "${var.delay_AVAILABILITY}"
severity_level = "AVAILABILITY"
tag_filter {
include_mode = "NONE"
include_mode = "${var.include_mode}"
dynamic "tag_filters" {
for_each = var.include_mode != "NONE" ? var.tag_filters : []
content {
context = tag_filters.value["context"]
key = tag_filters.value["key"]
value = tag_filters.value["value"]
}
}
}
}
@ -23,7 +31,15 @@ resource dynatrace_alerting_profile main {
delay_in_minutes = "${var.delay_CUSTOM_ALERT}"
severity_level = "CUSTOM_ALERT"
tag_filter {
include_mode = "NONE"
include_mode = "${var.include_mode}"
dynamic "tag_filters" {
for_each = var.include_mode != "NONE" ? var.tag_filters : []
content {
context = tag_filters.value["context"]
key = tag_filters.value["key"]
value = tag_filters.value["value"]
}
}
}
}
@ -31,7 +47,15 @@ resource dynatrace_alerting_profile main {
delay_in_minutes = "${var.delay_ERROR}"
severity_level = "ERROR"
tag_filter {
include_mode = "NONE"
include_mode = "${var.include_mode}"
dynamic "tag_filters" {
for_each = var.include_mode != "NONE" ? var.tag_filters : []
content {
context = tag_filters.value["context"]
key = tag_filters.value["key"]
value = tag_filters.value["value"]
}
}
}
}
@ -39,14 +63,30 @@ resource dynatrace_alerting_profile main {
delay_in_minutes = "${var.delay_MONITORING_UNAVAILABLE}"
severity_level = "MONITORING_UNAVAILABLE"
tag_filter {
include_mode = "NONE"
include_mode = "${var.include_mode}"
dynamic "tag_filters" {
for_each = var.include_mode != "NONE" ? var.tag_filters : []
content {
context = tag_filters.value["context"]
key = tag_filters.value["key"]
value = tag_filters.value["value"]
}
}
}
}
rules {
delay_in_minutes = "${var.delay_PERFORMANCE}"
severity_level = "PERFORMANCE"
tag_filter {
include_mode = "NONE"
include_mode = "${var.include_mode}"
dynamic "tag_filters" {
for_each = var.include_mode != "NONE" ? var.tag_filters : []
content {
context = tag_filters.value["context"]
key = tag_filters.value["key"]
value = tag_filters.value["value"]
}
}
}
}
@ -54,7 +94,15 @@ resource dynatrace_alerting_profile main {
delay_in_minutes = "${var.delay_RESOURCE_CONTENTION}"
severity_level = "RESOURCE_CONTENTION"
tag_filter {
include_mode = "NONE"
include_mode = "${var.include_mode}"
dynamic "tag_filters" {
for_each = var.include_mode != "NONE" ? var.tag_filters : []
content {
context = tag_filters.value["context"]
key = tag_filters.value["key"]
value = tag_filters.value["value"]
}
}
}
}

View File

@ -3,7 +3,6 @@ module ap1 {
source = "../../_dynatrace-base-modules/dynatrace-alerting-profile"
mzId = module.mz1.id
#mzId = "12323"
alertingProfileName = "Test123"
delay_AVAILABILITY = 0
delay_CUSTOM_ALERT = 10
@ -12,5 +11,18 @@ module ap1 {
delay_PERFORMANCE = 10
delay_RESOURCE_CONTENTION = 0
#Tag Filters
include_mode = "INCLUDE_ALL"
tag_filters = [{
context = "CONTEXTLESS"
key = "Environment"
value = "PROD"
},
{
context = "CONTEXTLESS"
key = "ms-id"
value = "ABC"
}
]
}