MON-487: Add Datadog monitor VM RAM used
MON-487: Fix variable MON-487: Fix variable 2 MON-487: Fix inputs MON-487: Fix query invalid MON-487: Change naming of variables and update README MON-487: Fix CI 2 MON-487: Increase timeframe from 5 min to 15min MON-487: Update README for timeframe increase
This commit is contained in:
parent
f149b6dd5e
commit
c3b22bfdef
@ -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
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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 = <<EOQ
|
||||
${var.ram_reserved_time_aggregator}(${var.ram_reserved_timeframe}):
|
||||
avg:azure.vm.memory_committed_bytes${module.filter-tags.query_alert} by {resource_group,region,name} / (
|
||||
avg:azure.vm.memory_committed_bytes${module.filter-tags.query_alert} by {resource_group,region,name} +
|
||||
avg:azure.vm.memory_available_bytes${module.filter-tags.query_alert} by {resource_group,region,name}) * 100
|
||||
> ${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"]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user