diff --git a/cloud/azure/virtual-machine/README.md b/cloud/azure/virtual-machine/README.md index 1980300..d4d346c 100644 --- a/cloud/azure/virtual-machine/README.md +++ b/cloud/azure/virtual-machine/README.md @@ -19,6 +19,7 @@ Creates DataDog monitors with the following checks: - Virtual Machine CPU usage - Virtual Machine credit CPU - Virtual Machine is unreachable +- Virtual Machine RAM reserved ## Inputs @@ -46,6 +47,13 @@ Creates DataDog monitors with the following checks: | message | Message sent when a Redis monitor is triggered | string | n/a | yes | | new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | | prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no | +| ram\_reserved\_enabled | Flag to enable Virtual Machine RAM reserved monitor | string | `"true"` | no | +| ram\_reserved\_extra\_tags | Extra tags for Virtual Machine RAM reserved monitor | list(string) | `[]` | no | +| ram\_reserved\_message | Custom message for Virtual Machine RAM reserved monitor | string | `""` | no | +| ram\_reserved\_threshold\_critical | Virtual Machine RAM reserved limit (critical threshold) | string | `"95"` | no | +| ram\_reserved\_threshold\_warning | Virtual Machine RAM reserved limit (warning threshold) | string | `"90"` | no | +| ram\_reserved\_time\_aggregator | Monitor aggregator for Virtual Machine RAM reserved [available values: min, max, sum or avg] | string | `"min"` | no | +| ram\_reserved\_timeframe | Monitor timeframe for Virtual Machine RAM reserved [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_15m"` | no | | status\_enabled | Flag to enable Virtual Machine status monitor | string | `"true"` | no | | status\_extra\_tags | Extra tags for Virtual Machine status monitor | list(string) | `[]` | no | | status\_message | Custom message for Virtual Machine status monitor | string | `""` | no | @@ -58,6 +66,7 @@ Creates DataDog monitors with the following checks: |------|-------------| | virtualmachine\_cpu\_usage\_id | id for monitor virtualmachine_cpu_usage | | virtualmachine\_credit\_cpu\_remaining\_too\_low\_id | id for monitor virtualmachine_credit_cpu_remaining_too_low | +| virtualmachine\_ram\_reserved\_id | id for monitor virtualmachine_ram_reserved | | virtualmachine\_status\_id | id for monitor virtualmachine_status | ## Related documentation diff --git a/cloud/azure/virtual-machine/inputs.tf b/cloud/azure/virtual-machine/inputs.tf index 087c19f..e217570 100644 --- a/cloud/azure/virtual-machine/inputs.tf +++ b/cloud/azure/virtual-machine/inputs.tf @@ -151,3 +151,44 @@ variable "cpu_remaining_rate_threshold_critical" { default = 15 } +variable "ram_reserved_enabled" { + description = "Flag to enable Virtual Machine RAM reserved monitor" + type = string + default = "true" +} + +variable "ram_reserved_message" { + description = "Custom message for Virtual Machine RAM reserved monitor" + type = string + default = "" +} + +variable "ram_reserved_extra_tags" { + description = "Extra tags for Virtual Machine RAM reserved monitor" + type = list(string) + default = [] +} + +variable "ram_reserved_time_aggregator" { + description = "Monitor aggregator for Virtual Machine RAM reserved [available values: min, max, sum or avg]" + type = string + default = "min" +} + +variable "ram_reserved_timeframe" { + description = "Monitor timeframe for Virtual Machine RAM reserved [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 "ram_reserved_threshold_warning" { + description = "Virtual Machine RAM reserved limit (warning threshold)" + default = 90 +} + +variable "ram_reserved_threshold_critical" { + description = "Virtual Machine RAM reserved limit (critical threshold)" + default = 95 +} + + diff --git a/cloud/azure/virtual-machine/monitors-virtual-machine.tf b/cloud/azure/virtual-machine/monitors-virtual-machine.tf index 5e11960..8aa4aac 100644 --- a/cloud/azure/virtual-machine/monitors-virtual-machine.tf +++ b/cloud/azure/virtual-machine/monitors-virtual-machine.tf @@ -98,3 +98,39 @@ EOQ } } +resource "datadog_monitor" "virtualmachine_ram_reserved" { + count = var.ram_reserved_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Virtual Machine RAM reserved {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = coalesce(var.ram_reserved_message, var.message) + type = "query alert" + + query = < ${var.ram_reserved_threshold_critical} +EOQ + + thresholds = { + critical = var.ram_reserved_threshold_critical + warning = var.ram_reserved_threshold_warning + } + + evaluation_delay = var.evaluation_delay + new_host_delay = var.new_host_delay + notify_no_data = false + renotify_interval = 0 + notify_audit = false + timeout_h = 0 + 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.ram_reserved_extra_tags) + + lifecycle { + ignore_changes = ["silenced"] + } +} + diff --git a/cloud/azure/virtual-machine/outputs.tf b/cloud/azure/virtual-machine/outputs.tf index 3141c8b..5863d30 100644 --- a/cloud/azure/virtual-machine/outputs.tf +++ b/cloud/azure/virtual-machine/outputs.tf @@ -13,3 +13,8 @@ output "virtualmachine_credit_cpu_remaining_too_low_id" { value = datadog_monitor.virtualmachine_credit_cpu_remaining_too_low.*.id } +output "virtualmachine_ram_reserved_id" { + description = "id for monitor virtualmachine_ram_reserved" + value = datadog_monitor.virtualmachine_ram_reserved.*.id +} +