forked from SumoLogic/terraform-sumologic-sumo-logic-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MariaDB.tf
459 lines (459 loc) · 20.2 KB
/
MariaDB.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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
module "MariaDB-NoindexusedintheSQLstatements" {
source = "SumoLogic/sumo-logic-monitor/sumologic"
#version = "{revision}"
monitor_name = "MariaDB - No index used in the SQL statements"
monitor_description = "This alert fires when there are 5 or more statements not using an index in the SQL query within a 5 minute time interval."
monitor_monitor_type = "Metrics"
monitor_parent_id = sumologic_monitor_folder.tf_monitor_folder_1.id
monitor_is_disabled = var.monitors_disabled
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
queries = {
A = "${var.mariadb_data_source} db_system=mariadb metric=mysql_perf_schema_events_statements_no_index_used_total db_cluster=* server=* schema=* | sum by db_cluster, host, server, schema"
}
triggers = [
{
threshold_type = "GreaterThanOrEqual",
threshold = 5,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "Critical",
detection_method = "StaticCondition"
},
{
threshold_type = "LessThan",
threshold = 5,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "ResolvedCritical",
detection_method = "StaticCondition"
}
]
}
module "MariaDB-Largenumberofslowqueries" {
source = "SumoLogic/sumo-logic-monitor/sumologic"
#version = "{revision}"
monitor_name = "MariaDB - Large number of slow queries"
monitor_description = "This alert fires when there are 5 or more slow queries within a 5 minute time interval."
monitor_monitor_type = "Metrics"
monitor_parent_id = sumologic_monitor_folder.tf_monitor_folder_1.id
monitor_is_disabled = var.monitors_disabled
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
queries = {
A = "${var.mariadb_data_source} db_system=mariadb metric=mysql_slow_queries db_cluster=* server=* | sum by db_cluster, host, server"
}
triggers = [
{
threshold_type = "GreaterThanOrEqual",
threshold = 5,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "Critical",
detection_method = "StaticCondition"
},
{
threshold_type = "LessThan",
threshold = 5,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "ResolvedCritical",
detection_method = "StaticCondition"
}
]
}
module "MariaDB-Followerreplicationlagdetected" {
source = "SumoLogic/sumo-logic-monitor/sumologic"
#version = "{revision}"
monitor_name = "MariaDB - Follower replication lag detected"
monitor_description = "This alert fires when we detect that the average replication lag within a 5 minute time interval is greater than or equal to 900 seconds ."
monitor_monitor_type = "Metrics"
monitor_parent_id = sumologic_monitor_folder.tf_monitor_folder_1.id
monitor_is_disabled = var.monitors_disabled
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
queries = {
A = "${var.mariadb_data_source} db_system=mariadb metric=mysql_slave_Seconds_Behind_Master db_cluster=* server=* host=* | avg by db_cluster, server, host"
B = "${var.mariadb_data_source} db_system=mariadb metric=mysql_slave_SQL_delay db_cluster=* server=* host=* | avg by db_cluster, server, host"
C = "(#A - #B) along db_cluster, server, host"
}
triggers = [
{
threshold_type = "GreaterThanOrEqual",
threshold = 900,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "Critical",
detection_method = "StaticCondition"
},
{
threshold_type = "LessThan",
threshold = 900,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "ResolvedCritical",
detection_method = "StaticCondition"
}
]
}
module "MariaDB-Largenumberofstatementerrors" {
source = "SumoLogic/sumo-logic-monitor/sumologic"
#version = "{revision}"
monitor_name = "MariaDB - Large number of statement errors"
monitor_description = "This alert fires when there are 5 or more statement errors within a 5 minute time interval."
monitor_monitor_type = "Metrics"
monitor_parent_id = sumologic_monitor_folder.tf_monitor_folder_1.id
monitor_is_disabled = var.monitors_disabled
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
queries = {
A = "${var.mariadb_data_source} db_system=mariadb metric=mysql_perf_schema_events_statements_errors_total db_cluster=* server=* schema=* | sum by db_cluster, host, server, schema"
}
triggers = [
{
threshold_type = "GreaterThanOrEqual",
threshold = 5,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "Critical",
detection_method = "StaticCondition"
},
{
threshold_type = "LessThan",
threshold = 5,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "ResolvedCritical",
detection_method = "StaticCondition"
}
]
}
module "MariaDB-Largenumberofstatementwarnings" {
source = "SumoLogic/sumo-logic-monitor/sumologic"
#version = "{revision}"
monitor_name = "MariaDB - Large number of statement warnings"
monitor_description = "This alert fires when we detect that there are 20 or more statement warnings within a 5 minute time interval."
monitor_monitor_type = "Metrics"
monitor_parent_id = sumologic_monitor_folder.tf_monitor_folder_1.id
monitor_is_disabled = var.monitors_disabled
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
queries = {
A = "${var.mariadb_data_source} db_system=mariadb metric=mysql_perf_schema_events_statements_warnings_total db_cluster=* server=* schema=* | sum by db_cluster, host, server, schema"
}
triggers = [
{
threshold_type = "GreaterThanOrEqual",
threshold = 20,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "Critical",
detection_method = "StaticCondition"
},
{
threshold_type = "LessThan",
threshold = 20,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "ResolvedCritical",
detection_method = "StaticCondition"
}
]
}
module "MariaDB-Instancedown" {
source = "SumoLogic/sumo-logic-monitor/sumologic"
#version = "{revision}"
monitor_name = "MariaDB - Instance down"
monitor_description = "This alert fires when we detect that a MariaDB instance is down"
monitor_monitor_type = "Logs"
monitor_parent_id = sumologic_monitor_folder.tf_monitor_folder_1.id
monitor_is_disabled = var.monitors_disabled
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
queries = {
A = "${var.mariadb_data_source} db_system=mariadb db_cluster=* (\"Shutdown complete\" or \"Terminated.\") | json \"log\" nodrop | if (_raw matches \"{*\", log, _raw) as mesg | parse regex field=mesg \"\\[(?<ErrorLogtype>[^\\]]*)][\\:]*\\s(?<ErrorMsg>.*)\" nodrop | \"Unknown\" as server_status | if (ErrorMsg matches \"*Terminated.*\", \"Down\", server_status) as server_status | if (ErrorMsg matches \"*Shutdown complete*\", \"Down\", server_status) as server_status | where server_status = \"Down\" | if (isEmpty(pod),_sourceHost,pod) as host | timeslice 1s | count by _timeslice, db_cluster,host,server_status,ErrorMsg"
}
triggers = [
{
threshold_type = "GreaterThanOrEqual",
threshold = 1,
time_range = "5m",
occurrence_type = "ResultCount"
trigger_source = "AllResults"
trigger_type = "Critical",
detection_method = "StaticCondition"
},
{
threshold_type = "LessThan",
threshold = 1,
time_range = "5m",
occurrence_type = "ResultCount"
trigger_source = "AllResults"
trigger_type = "ResolvedCritical",
detection_method = "StaticCondition"
}
]
}
module "MariaDB-Largenumberofabortedconnections" {
source = "SumoLogic/sumo-logic-monitor/sumologic"
#version = "{revision}"
monitor_name = "MariaDB - Large number of aborted connections"
monitor_description = "This alert fires when there are 5 or more aborted connections detected within a 5 minute time interval."
monitor_monitor_type = "Metrics"
monitor_parent_id = sumologic_monitor_folder.tf_monitor_folder_1.id
monitor_is_disabled = var.monitors_disabled
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
queries = {
A = "${var.mariadb_data_source} db_system=mariadb metric=mysql_aborted_connects db_cluster=* server=* | sum by db_cluster,host, server"
}
triggers = [
{
threshold_type = "GreaterThanOrEqual",
threshold = 5,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "Critical",
detection_method = "StaticCondition"
},
{
threshold_type = "LessThan",
threshold = 5,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "ResolvedCritical",
detection_method = "StaticCondition"
}
]
}
module "MariaDB-Connectionrefused" {
source = "SumoLogic/sumo-logic-monitor/sumologic"
#version = "{revision}"
monitor_name = "MariaDB - Connection refused"
monitor_description = "This alert fires when connections are refused when the limit of maximum connections is reached."
monitor_monitor_type = "Metrics"
monitor_parent_id = sumologic_monitor_folder.tf_monitor_folder_1.id
monitor_is_disabled = var.monitors_disabled
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
queries = {
A = "${var.mariadb_data_source} db_system=mariadb metric=mysql_connection_errors_max_connections db_cluster=* host=* server=* | sum by db_cluster, host, server"
}
triggers = [
{
threshold_type = "GreaterThanOrEqual",
threshold = 1,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "Critical",
detection_method = "StaticCondition"
},
{
threshold_type = "LessThan",
threshold = 1,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "ResolvedCritical",
detection_method = "StaticCondition"
}
]
}
module "MariaDB-SlaveServerError" {
source = "SumoLogic/sumo-logic-monitor/sumologic"
#version = "{revision}"
monitor_name = "MariaDB - Slave Server Error"
monitor_description = "This alert fires when slave server error within 5 minute time interval."
monitor_monitor_type = "Metrics"
monitor_parent_id = sumologic_monitor_folder.tf_monitor_folder_1.id
monitor_is_disabled = var.monitors_disabled
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
queries = {
C = "${var.mariadb_data_source} db_system=mariadb (metric=mysql_slave_last_io_errno or metric=mysql_slave_last_sql_errno) db_cluster=* | filter latest > 0 | sum by db_cluster,host,server"
}
triggers = [
{
threshold_type = "GreaterThan",
threshold = 0,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "Critical",
detection_method = "StaticCondition"
},
{
threshold_type = "LessThanOrEqual",
threshold = 0,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "ResolvedCritical",
detection_method = "StaticCondition"
}
]
}
module "MariaDB-HighInnodbbufferpoolutilization" {
source = "SumoLogic/sumo-logic-monitor/sumologic"
#version = "{revision}"
monitor_name = "MariaDB - High Innodb buffer pool utilization"
monitor_description = "This alert fires when the InnoDB buffer pool utilization is high (>=90%) within a 5 minute time interval."
monitor_monitor_type = "Metrics"
monitor_parent_id = sumologic_monitor_folder.tf_monitor_folder_1.id
monitor_is_disabled = var.monitors_disabled
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
queries = {
A = "${var.mariadb_data_source} db_system=mariadb metric=mysql_Innodb_buffer_pool_pages_total db_cluster=* server=* | sum by db_cluster, host, server"
B = "${var.mariadb_data_source} db_system=mariadb metric=mysql_Innodb_buffer_pool_pages_free db_cluster=* server=* | sum by db_cluster, host, server"
C = "((#A - #B) / #A) * 100 along db_cluster, host, server"
}
triggers = [
{
threshold_type = "GreaterThanOrEqual",
threshold = 90,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "Critical",
detection_method = "StaticCondition"
},
{
threshold_type = "LessThan",
threshold = 90,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "ResolvedCritical",
detection_method = "StaticCondition"
}
]
}
module "MariaDB-ExcessiveSlowQueryDetected" {
source = "SumoLogic/sumo-logic-monitor/sumologic"
#version = "{revision}"
monitor_name = "MariaDB - Excessive Slow Query Detected"
monitor_description = "This alert fires when the average time to execute a query is more than 15 seconds for a 5 minute time interval."
monitor_monitor_type = "Logs"
monitor_parent_id = sumologic_monitor_folder.tf_monitor_folder_1.id
monitor_is_disabled = var.monitors_disabled
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
queries = {
A = "db_system=mariadb db_cluster=* \"User@Host\" \"Query_time\" | json auto maxdepth 1 nodrop | if (isEmpty(log), _raw, log) as mariadb_log_message | parse regex field=mariadb_log_message \"(?<query_block># User@Host:[\\S\\s]+?SET timestamp=\\d+;[\\S\\s]+?;)\" multi | parse regex field=query_block \"Schema: (?<schema>(?:\\S*|\\s)?)\\s*Last_errno[\\s\\S]+?Query_time:\\s+(?<query_time>[\\d.]*)\\s+Lock_time:\\s+(?<lock_time>[\\d.]*)\\s+Rows_sent:\\s+(?<rows_sent>[\\d.]*)\\s+Rows_examined:\\s+(?<rows_examined>[\\d.]*)\\s+Rows_affected:\\s+(?<rows_affected>[\\d.]*)\\s+Rows_read:\\s+(?<rows_read>[\\d.]*)\\n\" nodrop // Pttrn2-vrtn1 | parse regex field=query_block \"Schema: (?<schema>(?:\\S*|\\s)?)\\s*Last_errno[\\s\\S]+?\\s+Killed:\\s+\\d+\\n\" nodrop // Pttrn2-vrtn2 | parse regex field=query_block \"Query_time:\\s+(?<query_time>[\\d.]*)\\s+Lock_time:\\s+(?<lock_time>[\\d.]*)\\s+Rows_sent:\\s+(?<rows_sent>[\\d]*)\\s+Rows_examined:\\s+(?<rows_examined>[\\d]*)\\s+Rows_affected:\\s+(?<rows_affected>[\\d]*)\\s+\" nodrop // Pttrn2-vrtn3 | parse regex field=query_block \"Query_time:\\s+(?<query_time>[\\d.]*)\\s+Lock_time:\\s+(?<lock_time>[\\d.]*)\\s+Rows_sent:\\s+(?<rows_sent>[\\d]*)\\s+Rows_examined:\\s+(?<rows_examined>[\\d]*)\" // Pttrn2-vrtn4 | fields -query_block | num (query_time) | count as frequency, sum(query_time) as total_time, min(query_time) as min_time, max(query_time) as max_time, avg(query_time) as avg_time, avg(rows_examined) as avg_rows_examined, avg(rows_sent) as avg_rows_sent, avg(Lock_Time) as avg_lock_time group by sql_cmd, db_cluster, schema | 15 as threshold // customize if need different value. As an example, query taking more than 15 Seconds is considered as Excessive Slow. | where avg_time > threshold | sort by avg_time, frequency asc"
}
triggers = [
{
threshold_type = "GreaterThanOrEqual",
threshold = 1,
time_range = "1d",
occurrence_type = "ResultCount"
trigger_source = "AllResults"
trigger_type = "Critical",
detection_method = "StaticCondition"
},
{
threshold_type = "LessThan",
threshold = 1,
time_range = "1d",
occurrence_type = "ResultCount"
trigger_source = "AllResults"
trigger_type = "ResolvedCritical",
detection_method = "StaticCondition"
}
]
}
module "MariaDB-Largenumberofinternalconnectionerrors" {
source = "SumoLogic/sumo-logic-monitor/sumologic"
#version = "{revision}"
monitor_name = "MariaDB - Large number of internal connection errors"
monitor_description = "This alert fires when there are 5 or more internal connection errors within a 5 minute time interval."
monitor_monitor_type = "Metrics"
monitor_parent_id = sumologic_monitor_folder.tf_monitor_folder_1.id
monitor_is_disabled = var.monitors_disabled
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
queries = {
A = "${var.mariadb_data_source} db_system=mariadb metric=mysql_connection_errors_internal db_cluster=* server=* | sum by db_cluster, host, server"
}
triggers = [
{
threshold_type = "GreaterThanOrEqual",
threshold = 5,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "Critical",
detection_method = "StaticCondition"
},
{
threshold_type = "LessThan",
threshold = 5,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "ResolvedCritical",
detection_method = "StaticCondition"
}
]
}
module "MariaDB-Highaveragequeryruntime" {
source = "SumoLogic/sumo-logic-monitor/sumologic"
#version = "{revision}"
monitor_name = "MariaDB - High average query run time"
monitor_description = "This alert fires when the average run time of MariaDB queries within a 5 minute time interval for a given schema is greater than or equal to one second."
monitor_monitor_type = "Metrics"
monitor_parent_id = sumologic_monitor_folder.tf_monitor_folder_1.id
monitor_is_disabled = var.monitors_disabled
group_notifications = var.group_notifications
connection_notifications = var.connection_notifications
email_notifications = var.email_notifications
queries = {
A = "${var.mariadb_data_source} db_system=mariadb metric=mysql_perf_schema_events_statements_seconds_total db_cluster=* server=* schema=* | avg by db_cluster, host, server, schema"
}
triggers = [
{
threshold_type = "GreaterThanOrEqual",
threshold = 1,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "Critical",
detection_method = "StaticCondition"
},
{
threshold_type = "LessThan",
threshold = 1,
time_range = "5m",
occurrence_type = "Always"
trigger_source = "AnyTimeSeries"
trigger_type = "ResolvedCritical",
detection_method = "StaticCondition"
}
]
}