Skip to content

Commit

Permalink
Merge pull request #42 from claranet/migrate_event_monitors
Browse files Browse the repository at this point in the history
Migrate event monitors
  • Loading branch information
Aohzan authored Feb 13, 2023
2 parents 475a2e1 + c384249 commit 9a7cbc7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
8 changes: 2 additions & 6 deletions caas/kubernetes/node/monitors-k8s-node.tf
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,11 @@ resource "datadog_monitor" "unregister_net_device" {
count = var.unregister_net_device_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kubernetes Node Frequent unregister net device"
message = coalesce(var.unregister_net_device_message, var.message)
type = "event alert"
type = "event-v2 alert"

query = <<EOQ
events('sources:kubernetes priority:all ${module.filter-tags.event_alert} \"UnregisterNetDevice\"').rollup('count').last('${var.unregister_net_device_timeframe}') > ${var.unregister_net_device_threshold_critical}
EOQ
query = "events(\"sources:kubernetes ${module.filter-tags.event_alert} \"UnregisterNetDevice\"\").rollup(\"count\").last(\"${var.unregister_net_device_timeframe}\") >= ${var.unregister_net_device_threshold_critical}"

new_host_delay = var.new_host_delay
new_group_delay = var.new_group_delay
notify_no_data = false
renotify_interval = 0
notify_audit = false
Expand Down Expand Up @@ -272,4 +269,3 @@ EOQ

tags = concat(["env:${var.environment}", "type:caas", "provider:kubernetes", "resource:kubernetes-node", "team:claranet", "created-by:terraform"], var.volume_inodes_extra_tags)
}

3 changes: 3 additions & 0 deletions common/filter-tags/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ locals {
std_including_string = replace("${replace(local.including_string, "${var.filter_tags_separator}", "${local.filter_tags_separator}")}", "/ +/", " ")
std_excluding_string = replace("${replace(local.excluding_string, "${var.filter_tags_separator}", "${local.filter_tags_separator}")}", "/ +/", " ")

event_including_string = replace("${replace(local.including_string, "${var.filter_tags_separator}", " ")}", "/ +/", " ")
event_excluding_string = replace("${replace(local.excluding_string, "${var.filter_tags_separator}", " -")}", "/ +/", " ")

including_string = var.filter_tags_use_defaults == "true" ? join(local.filter_tags_separator, local.including_default_list) : join(local.filter_tags_separator, local.including_custom_list)
excluding_string = join(local.filter_tags_separator, local.excluding_list)

Expand Down
2 changes: 1 addition & 1 deletion common/filter-tags/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ output "service_check" {
# event_alert = tags:tag:val,tag2:val2 excluded_tags:excludedtag:value,exludedtag2:value2
output "event_alert" {
description = "The full filtering pattern for event alert monitor type"
value = "tags:(${local.std_including_string})${local.std_excluding_string == "" ? "" : " excluded_tags:(${local.std_excluding_string})"}"
value = "${local.event_including_string}${local.event_excluding_string == "" ? "" : local.event_excluding_string}"
}

0 comments on commit 9a7cbc7

Please sign in to comment.