-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path05_alert_node.tf
253 lines (214 loc) · 8.66 KB
/
05_alert_node.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
##############
### Alerts ###
##############
# Policy
resource "newrelic_alert_policy" "node" {
name = "K8s | ${var.cluster_name} | Nodes"
incident_preference = "PER_CONDITION"
}
# Condition - Status
resource "newrelic_nrql_alert_condition" "node_status" {
account_id = var.NEW_RELIC_ACCOUNT_ID
policy_id = newrelic_alert_policy.node.id
type = "static"
name = "Node status"
description = <<-EOT
Your node is down!
EOT
enabled = true
violation_time_limit_seconds = 86400
nrql {
query = "FROM Metric SELECT latest(up) WHERE instrumentation.provider = 'opentelemetry' AND k8s.cluster.name = '${var.cluster_name}' AND service.name = 'kubernetes-node-exporter' FACET k8s.node.name"
}
critical {
operator = "below"
threshold = 1
threshold_duration = 300
threshold_occurrences = "all"
}
fill_option = "none"
aggregation_window = 60
aggregation_method = "event_timer"
aggregation_timer = 5
}
# Condition - CPU utilization too high
resource "newrelic_nrql_alert_condition" "node_cpu_utilization_high" {
account_id = var.NEW_RELIC_ACCOUNT_ID
policy_id = newrelic_alert_policy.node.id
type = "static"
name = "CPU utilization too high"
description = <<-EOT
Your node is about to reach its maximum CPU capacity!
- Check the workloads running on it to see which applications are consuming the most CPU.
- Check if your cluster scaler has already kicked in and provisioning an additional node.
EOT
enabled = true
violation_time_limit_seconds = 86400
nrql {
query = "FROM Metric SELECT rate(filter(sum(node_cpu_seconds_total), WHERE mode != 'idle'), 1 SECONDS)/uniqueCount(cpu)*100 WHERE instrumentation.provider = 'opentelemetry' AND k8s.cluster.name = '${var.cluster_name}' AND service.name = 'kubernetes-node-exporter' FACET k8s.node.name"
}
critical {
operator = "above"
threshold = 90
threshold_duration = 300
threshold_occurrences = "all"
}
warning {
operator = "above"
threshold = 75
threshold_duration = 300
threshold_occurrences = "all"
}
fill_option = "none"
aggregation_window = 60
aggregation_method = "event_flow"
aggregation_delay = 0
}
# Condition - CPU utilization too low
resource "newrelic_nrql_alert_condition" "node_cpu_utilization_low" {
account_id = var.NEW_RELIC_ACCOUNT_ID
policy_id = newrelic_alert_policy.node.id
type = "static"
name = "CPU utilization too low"
description = <<-EOT
Your node is not benefiting from the CPU capacity it has been given!
- Check if your node is using its assigned memory properly.
- If yes, change your VM type. Pick yourself a memory-optimized VM in order not to pay for the unnecessary CPU which you don't use.
- If not, scale down your VM. Pick yourself a smaller VM to pay only for what you actually use.
EOT
enabled = true
violation_time_limit_seconds = 86400
nrql {
query = "FROM Metric SELECT rate(filter(sum(node_cpu_seconds_total), WHERE mode != 'idle'), 1 SECONDS)/uniqueCount(cpu)*100 WHERE instrumentation.provider = 'opentelemetry' AND k8s.cluster.name = '${var.cluster_name}' AND service.name = 'kubernetes-node-exporter' FACET k8s.node.name"
}
critical {
operator = "below"
threshold = 20
threshold_duration = 43200
threshold_occurrences = "all"
}
fill_option = "none"
aggregation_window = 300
aggregation_method = "event_flow"
aggregation_delay = 0
}
# Condition - MEM utilization too high
resource "newrelic_nrql_alert_condition" "node_mem_utilization_high" {
account_id = var.NEW_RELIC_ACCOUNT_ID
policy_id = newrelic_alert_policy.node.id
type = "static"
name = "MEM utilization too high"
description = <<-EOT
Your node is about to reach its maximum memory capacity!
- Check the workloads running on it to see which applications are consuming the most memory.
- Check if your cluster scaler has already kicked in and provisioning an additional node.
EOT
enabled = true
violation_time_limit_seconds = 86400
nrql {
query = "FROM Metric SELECT (100 * (1 - ((average(node_memory_MemFree_bytes) + average(node_memory_Cached_bytes) + average(node_memory_Buffers_bytes)) / average(node_memory_MemTotal_bytes)))) WHERE instrumentation.provider = 'opentelemetry' AND k8s.cluster.name = '${var.cluster_name}' AND service.name = 'kubernetes-node-exporter' FACET k8s.node.name"
}
critical {
operator = "above"
threshold = 90
threshold_duration = 300
threshold_occurrences = "all"
}
warning {
operator = "above"
threshold = 75
threshold_duration = 300
threshold_occurrences = "all"
}
fill_option = "none"
aggregation_window = 60
aggregation_method = "event_flow"
aggregation_delay = 0
}
# Condition - MEM utilization too low
resource "newrelic_nrql_alert_condition" "node_mem_utilization_low" {
account_id = var.NEW_RELIC_ACCOUNT_ID
policy_id = newrelic_alert_policy.node.id
type = "static"
name = "MEM utilization too low"
description = <<-EOT
Your node is not benefiting from the memory capacity it has been given!
- Check if your node is using its CPU memory properly.
- If yes, change your VM type. Pick yourself a CPU-optimized VM in order not to pay for the unnecessary memory which you don't use.
- If not, scale down your VM. Pick yourself a smaller VM to pay only for what you actually use.
EOT
enabled = true
violation_time_limit_seconds = 86400
nrql {
query = "FROM Metric SELECT (100 * (1 - ((average(node_memory_MemFree_bytes) + average(node_memory_Cached_bytes) + average(node_memory_Buffers_bytes)) / average(node_memory_MemTotal_bytes)))) WHERE instrumentation.provider = 'opentelemetry' AND k8s.cluster.name = '${var.cluster_name}' AND service.name = 'kubernetes-node-exporter' FACET k8s.node.name"
}
critical {
operator = "below"
threshold = 40
threshold_duration = 43200
threshold_occurrences = "all"
}
fill_option = "none"
aggregation_window = 300
aggregation_method = "event_flow"
aggregation_delay = 0
}
# Condition - STO utilization too high
resource "newrelic_nrql_alert_condition" "node_sto_utilization_high" {
account_id = var.NEW_RELIC_ACCOUNT_ID
policy_id = newrelic_alert_policy.node.id
type = "static"
name = "STO utilization too high"
description = <<-EOT
Your node is about to reach its maximum storage capacity!
- Check the workloads running on it to see which applications are consuming the most storage.
- Check if you can extend the underlying storage.
EOT
enabled = true
violation_time_limit_seconds = 86400
nrql {
query = "SELECT (1 - (average(node_filesystem_avail_bytes) / average(node_filesystem_size_bytes))) * 100 FROM Metric WHERE instrumentation.provider = 'opentelemetry' AND k8s.cluster.name = '${var.cluster_name}' AND service.name = 'kubernetes-node-exporter' FACET k8s.node.name"
}
critical {
operator = "above"
threshold = 90
threshold_duration = 300
threshold_occurrences = "all"
}
warning {
operator = "above"
threshold = 75
threshold_duration = 300
threshold_occurrences = "all"
}
fill_option = "none"
aggregation_window = 60
aggregation_method = "event_flow"
aggregation_delay = 0
}
# Condition - STO utilization too low
resource "newrelic_nrql_alert_condition" "node_sto_utilization_low" {
account_id = var.NEW_RELIC_ACCOUNT_ID
policy_id = newrelic_alert_policy.node.id
type = "static"
name = "STO utilization too low"
description = <<-EOT
Your node is not benefiting from the storage capacity it has been given!
- Check what sort of IOPS your node is using on the disk and pick yourself a smaller disk.
EOT
enabled = true
violation_time_limit_seconds = 86400
nrql {
query = "SELECT (1 - (average(node_filesystem_avail_bytes) / average(node_filesystem_size_bytes))) * 100 FROM Metric WHERE instrumentation.provider = 'opentelemetry' AND k8s.cluster.name = '${var.cluster_name}' AND service.name = 'kubernetes-node-exporter' FACET k8s.node.name"
}
critical {
operator = "below"
threshold = 40
threshold_duration = 43200
threshold_occurrences = "all"
}
fill_option = "none"
aggregation_window = 300
aggregation_method = "event_flow"
aggregation_delay = 0
}