MON-301 add support for excluding on service check

This commit is contained in:
Quentin Manfroi 2018-10-02 13:53:19 +02:00
parent 9c3afce524
commit 50811d98de
5 changed files with 19 additions and 12 deletions

View File

@ -14,12 +14,17 @@ variable "filter_tags_use_defaults" {
} }
variable "filter_tags_custom" { variable "filter_tags_custom" {
description = "Tags used for custom filtering when filter_tags_use_defaults is false" description = "Tags used for custom filtering when filter_tags_use_defaults is false (i.e. \"tag1:val1,tag2:val2\")"
default = "*" default = "*"
} }
variable "filter_tags_custom_excluded" {
description = "Tags excluded for custom filtering when filter_tags_use_defaults is false (i.e. \"tag1:val1,tag2:val2\")"
default = ""
}
variable "extra_tags" { variable "extra_tags" {
description = "Extra optional tags (i.e. [\"tag1:val1\", \"tag2:val2\"])" description = "Extra optional tags added for default filtering when filter_tags_use_defaults is true (i.e. [\"tag1:val1\", \"tag2:val2\"])"
type = "list" type = "list"
default = [] default = []
} }

View File

@ -1,3 +1,4 @@
locals { locals {
filters = "${var.filter_tags_use_defaults == "true" ? join(",", compact(concat(split(",", format("dd_monitoring:enabled,dd_%s:enabled,env:%s", var.resource, var.environment)), compact(var.extra_tags)))) : "${var.filter_tags_custom}"}" including = "${var.filter_tags_use_defaults == "true" ? join(",", compact(concat(split(",", format("dd_monitoring:enabled,dd_%s:enabled,env:%s", var.resource, var.environment)), compact(var.extra_tags)))) : "${var.filter_tags_custom}"}"
excluding = "${join(",", compact(split(",", "${var.filter_tags_custom_excluded}")))}"
} }

View File

@ -1,9 +0,0 @@
output "query_alert" {
description = "The full filtering pattern including parentheses for service check monitor type"
value = "{${local.filters}}"
}
output "service_check" {
description = "The full filtering pattern including braces for query alert monitor type"
value = "(\"${replace(local.filters, ",", "\",\"")}\")"
}

View File

@ -0,0 +1,10 @@
output "query_alert" {
description = "The full filtering pattern including parentheses for service check monitor type"
value = "{${join(",", compact(concat(list(local.including), formatlist("!%s", compact(split(",", local.excluding))))))}}"
}
output "service_check" {
description = "The full filtering pattern including braces for query alert monitor type"
#value = "over.(\"${replace(local.including, ",", "\",\"")}\").exclude(\"${replace(local.excluding, ",", "\",\"")}\")"
value = ".over(\"${replace(local.including, ",", "\",\"")}\")${local.excluding == "" ? "" : ".exclude(\"${replace(local.excluding, ",", "\",\"")}\")"}"
}