-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
101 lines (90 loc) · 3.13 KB
/
main.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
resource "aws_cloudwatch_metric_alarm" "burst_balance_too_low" {
alarm_name = "${var.prefix}efs-${var.efs_id}-lowBurstBalance"
comparison_operator = "LessThanThreshold"
evaluation_periods = var.evaluation_period
metric_name = "BurstCreditBalance"
namespace = "AWS/EFS"
period = var.statistic_period
statistic = "Average"
threshold = "100000000000" # 100 GB in Bytes
alarm_description = "Average burst credit balance is low, a performance impact will occur within the hour."
alarm_actions = var.actions_alarm
ok_actions = var.actions_ok
dimensions = {
FileSystemId = var.efs_id
}
}
resource "aws_cloudwatch_metric_alarm" "io_percentage_too_high" {
alarm_name = "${var.prefix}efs-${var.efs_id}-highIOPercentage"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = var.evaluation_period
metric_name = "PercentIOLimit"
namespace = "AWS/EFS"
period = var.statistic_period
statistic = "Maximum"
threshold = "90"
alarm_description = "I/O limit has been reached, consider using Max I/O performance mode."
alarm_actions = var.actions_alarm
ok_actions = var.actions_ok
dimensions = {
FileSystemId = var.efs_id
}
}
resource "aws_cloudwatch_metric_alarm" "anomalous_client_connections" {
alarm_name = "${var.prefix}efs-${var.efs_id}-anomalousClientConnections"
comparison_operator = "GreaterThanUpperThreshold"
evaluation_periods = var.evaluation_period
threshold_metric_id = "e1"
alarm_description = "Anomalous database connection count detected. Something unusual is happening."
alarm_actions = var.actions_alarm
ok_actions = var.actions_ok
metric_query {
id = "e1"
expression = "ANOMALY_DETECTION_BAND(m1)"
label = "ClientConnections (Expected)"
return_data = "true"
}
metric_query {
id = "m1"
return_data = "true"
metric {
metric_name = "ClientConnections"
namespace = "AWS/EFS"
period = var.anomaly_period
stat = "Average"
unit = "Count"
dimensions = {
FileSystemId = var.efs_id
}
}
}
}
resource "aws_cloudwatch_metric_alarm" "anomalous_io_bytes" {
alarm_name = "${var.prefix}efs-${var.efs_id}-anomalousIOBytes"
comparison_operator = "GreaterThanUpperThreshold"
evaluation_periods = var.evaluation_period
threshold_metric_id = "e1"
alarm_description = "Anomalous IO pattern detected. Something unusual is happening."
alarm_actions = var.actions_alarm
ok_actions = var.actions_ok
metric_query {
id = "e1"
expression = "ANOMALY_DETECTION_BAND(m1)"
label = "TotalIOBytes (Expected)"
return_data = "true"
}
metric_query {
id = "m1"
return_data = "true"
metric {
metric_name = "TotalIOBytes"
namespace = "AWS/EFS"
period = var.anomaly_period
stat = "Average"
unit = "Count"
dimensions = {
FileSystemId = var.efs_id
}
}
}
}