MON-489 Add monitor free disk space

This commit is contained in:
gauthier.ampe@fr.clara.net 2019-08-02 17:27:41 +02:00
parent 39eb1b5d39
commit 1dce1a96d4
2 changed files with 72 additions and 1 deletions

View File

@ -191,4 +191,42 @@ variable "ram_reserved_threshold_critical" {
default = 95 default = 95
} }
variable "filesystem_free_disk_space_low_enabled" {
description = "Flag to enable Virtual Machine status monitor"
type = string
default = "true"
}
variable "filesystem_free_disk_space_low_time_aggregator" {
description = "Monitor aggregator for Virtual Machine free disk space [available values: min, max or avg]"
type = string
default = "avg"
}
variable "filesystem_free_disk_space_low_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`]"
type = string
default = "last_15m"
}
variable "filesystem_free_disk_space_low_threshold_critical" {
description = "Virtual Machine free disk space in percent (critical threshold)"
default = "5"
}
variable "filesystem_free_disk_space_low_threshold_warning" {
description = "Virtual Machine free disk space in percent (warning threshold)"
default = "10"
}
variable "filesystem_free_disk_space_low_extra_tags" {
description = "Extra tags for Virtual Machine free disk space monitor"
type = list(string)
default = []
}
variable "filesystem_free_disk_space_low_message" {
description = "Custom message for Virtual Machine CPU free disk space monitor"
type = string
default = ""
}

View File

@ -134,3 +134,36 @@ EOQ
} }
} }
resource "datadog_monitor" "virtualmachine_free_filesystem_disk_space_low" {
count = var.filesystem_free_disk_space_low_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Virtual Machine filesystem disk space too low {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = coalesce(var.filesystem_free_disk_space_low_message, var.message)
type = "query alert"
query = <<EOQ
${var.filesystem_free_disk_space_low_time_aggregator}(${var.filesystem_free_disk_space_low_timeframe}): (
avg:azure.vm.builtin_filesystem_percentfreespace${module.filter-tags.query_alert} by {resource_group,region,name}
) < ${var.filesystem_free_disk_space_low_threshold_critical}
EOQ
thresholds = {
warning = var.filesystem_free_disk_space_low_threshold_warning
critical = var.filesystem_free_disk_space_low_threshold_critical
}
evaluation_delay = var.evaluation_delay
new_host_delay = var.new_host_delay
notify_no_data = false
renotify_interval = 0
notify_audit = false
timeout_h = 1
include_tags = true
locked = false
require_full_window = false
tags = concat(["env:${var.environment}", "type:cloud", "provider:azure", "resource:virtualmachine", "team:claranet", "created-by:terraform"], var.filesystem_free_disk_space_low_extra_tags)
lifecycle {
ignore_changes = ["silenced"]
}
}