-
Notifications
You must be signed in to change notification settings - Fork 2
/
alerts.tf
71 lines (63 loc) · 2.82 KB
/
alerts.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
resource "azurerm_monitor_metric_alert" "db_alert_cpu" {
count = var.email_address_key == "" || var.email_address_key_vault_id == "" ? 0 : 1
name = "db_cpu_percent_${local.server_name}"
resource_group_name = local.postgresql_rg_name
scopes = [azurerm_postgresql_flexible_server.pgsql_server.id]
description = "Whenever the cpu utilization is greater than ${var.cpu_threshold}%"
severity = var.alert_severity
frequency = var.alert_frequency
window_size = var.alert_window_size
tags = var.common_tags
criteria {
metric_namespace = "Microsoft.DBforPostgreSQL/flexibleServers"
metric_name = "cpu_percent"
aggregation = "Average"
operator = "GreaterThanOrEqual"
threshold = var.cpu_threshold
}
action {
action_group_id = azurerm_monitor_action_group.db-alerts-action-group[count.index].id
}
}
resource "azurerm_monitor_metric_alert" "db_alert_memory" {
count = var.email_address_key == "" || var.email_address_key_vault_id == "" ? 0 : 1
name = "db_memory_percent_${local.server_name}"
resource_group_name = local.postgresql_rg_name
scopes = [azurerm_postgresql_flexible_server.pgsql_server.id]
description = "Whenever the memory utilization is greater than ${var.memory_threshold}%"
severity = var.alert_severity
frequency = var.alert_frequency
window_size = var.alert_window_size
tags = var.common_tags
criteria {
metric_namespace = "Microsoft.DBforPostgreSQL/flexibleServers"
metric_name = "memory_percent"
aggregation = "Average"
operator = "GreaterThanOrEqual"
threshold = var.memory_threshold
}
action {
action_group_id = azurerm_monitor_action_group.db-alerts-action-group[count.index].id
}
}
resource "azurerm_monitor_metric_alert" "db_alert_storage_utilization" {
count = var.email_address_key == "" || var.email_address_key_vault_id == "" ? 0 : 1
name = "db_storage_utilization_${local.server_name}"
resource_group_name = local.postgresql_rg_name
scopes = [azurerm_postgresql_flexible_server.pgsql_server.id]
description = "Whenever the storage utilization is greater than ${var.storage_threshold}%"
severity = var.alert_severity
frequency = var.alert_frequency
window_size = var.alert_window_size
tags = var.common_tags
criteria {
metric_namespace = "Microsoft.DBforPostgreSQL/flexibleServers"
metric_name = "storage_percent"
aggregation = "Average"
operator = "GreaterThanOrEqual"
threshold = var.storage_threshold
}
action {
action_group_id = azurerm_monitor_action_group.db-alerts-action-group[count.index].id
}
}