MON-489 use greater logic instead of lower

This commit is contained in:
gauthier.ampe@fr.clara.net 2019-08-06 10:47:12 +02:00
parent 8c36e686d4
commit 689ed65dd1
2 changed files with 19 additions and 19 deletions

View File

@ -191,41 +191,41 @@ variable "ram_reserved_threshold_critical" {
default = 95 default = 95
} }
variable "free_disk_space_low_enabled" { variable "disk_space_enabled" {
description = "Flag to enable Virtual Machine status monitor" description = "Flag to enable Virtual Machine status monitor"
type = string type = string
default = "true" default = "true"
} }
variable "free_disk_space_low_time_aggregator" { variable "disk_space_time_aggregator" {
description = "Monitor aggregator for Virtual Machine free disk space [available values: min, max or avg]" description = "Monitor aggregator for Virtual Machine free disk space [available values: min, max or avg]"
type = string type = string
default = "avg" default = "avg"
} }
variable "free_disk_space_low_timeframe" { variable "disk_space_timeframe" {
description = "Monitor timeframe for Virtual Machine free disk space too low [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" description = "Monitor timeframe for Virtual Machine free disk space too low [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = string type = string
default = "last_15m" default = "last_15m"
} }
variable "free_disk_space_low_threshold_critical" { variable "disk_space_threshold_critical" {
description = "Virtual Machine free disk space in percent (critical threshold)" description = "Virtual Machine free disk space in percent (critical threshold)"
default = "5" default = "95"
} }
variable "free_disk_space_low_threshold_warning" { variable "disk_space_threshold_warning" {
description = "Virtual Machine free disk space in percent (warning threshold)" description = "Virtual Machine free disk space in percent (warning threshold)"
default = "10" default = "90"
} }
variable "free_disk_space_low_extra_tags" { variable "disk_space_extra_tags" {
description = "Extra tags for Virtual Machine free disk space monitor" description = "Extra tags for Virtual Machine free disk space monitor"
type = list(string) type = list(string)
default = [] default = []
} }
variable "free_disk_space_low_message" { variable "disk_space_message" {
description = "Custom message for Virtual Machine CPU free disk space monitor" description = "Custom message for Virtual Machine CPU free disk space monitor"
type = string type = string
default = "" default = ""

View File

@ -134,21 +134,21 @@ EOQ
} }
} }
resource "datadog_monitor" "virtualmachine_free_disk_space_low" { resource "datadog_monitor" "virtualmachine_disk_space" {
count = var.free_disk_space_low_enabled == "true" ? 1 : 0 count = var.disk_space_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Virtual Machine disk space too low {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Virtual Machine disk space {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = coalesce(var.free_disk_space_low_message, var.message) message = coalesce(var.disk_space_message, var.message)
type = "query alert" type = "query alert"
query = <<EOQ query = <<EOQ
${var.free_disk_space_low_time_aggregator}(${var.free_disk_space_low_timeframe}): ${var.disk_space_time_aggregator}(${var.disk_space_timeframe}):
avg:azure.vm.builtin_filesystem_percentfreespace${module.filter-tags.query_alert} by {resource_group,region,name} avg:azure.vm.builtin_filesystem_percentusedspace${module.filter-tags.query_alert} by {resource_group,region,name}
< ${var.free_disk_space_low_threshold_critical} > ${var.disk_space_threshold_critical}
EOQ EOQ
thresholds = { thresholds = {
warning = var.free_disk_space_low_threshold_warning warning = var.disk_space_threshold_warning
critical = var.free_disk_space_low_threshold_critical critical = var.disk_space_threshold_critical
} }
evaluation_delay = var.evaluation_delay evaluation_delay = var.evaluation_delay
@ -161,7 +161,7 @@ EOQ
locked = false locked = false
require_full_window = false require_full_window = false
tags = concat(["env:${var.environment}", "type:cloud", "provider:azure", "resource:virtualmachine", "team:claranet", "created-by:terraform"], var.free_disk_space_low_extra_tags) tags = concat(["env:${var.environment}", "type:cloud", "provider:azure", "resource:virtualmachine", "team:claranet", "created-by:terraform"], var.disk_space_extra_tags)
lifecycle { lifecycle {
ignore_changes = ["silenced"] ignore_changes = ["silenced"]