-
Notifications
You must be signed in to change notification settings - Fork 0
/
alarms.tf
137 lines (123 loc) · 5.37 KB
/
alarms.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
locals {
thresholds = {
BurstBalanceThreshold = "${min(max(var.burst_balance_threshold, 0), 100)}"
CPUUtilizationThreshold = "${min(max(var.cpu_utilization_threshold, 0), 100)}"
CPUCreditBalanceThreshold = "${max(var.cpu_credit_balance_threshold, 0)}"
DiskQueueDepthThreshold = "${max(var.disk_queue_depth_threshold, 0)}"
FreeableMemoryThreshold = "${max(var.freeable_memory_threshold, 0)}"
FreeStorageSpaceThreshold = "${max(var.free_storage_space_threshold, 0)}"
SwapUsageThreshold = "${max(var.swap_usage_threshold, 0)}"
}
}
resource "aws_cloudwatch_metric_alarm" "burst_balance_too_low" {
alarm_name = "burst_balance_too_low"
comparison_operator = "LessThanThreshold"
evaluation_periods = "1"
metric_name = "BurstBalance"
namespace = "AWS/RDS"
period = "600"
statistic = "Average"
threshold = "${local.thresholds["BurstBalanceThreshold"]}"
alarm_description = "Average database storage burst balance over last 10 minutes too low, expect a significant performance drop soon"
alarm_actions = ["${aws_sns_topic.default.arn}"]
ok_actions = ["${aws_sns_topic.default.arn}"]
dimensions {
DBInstanceIdentifier = "${var.db_instance_id}"
}
}
resource "aws_cloudwatch_metric_alarm" "cpu_utilization_too_high" {
alarm_name = "cpu_utilization_too_high"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = "1"
metric_name = "CPUUtilization"
namespace = "AWS/RDS"
period = "600"
statistic = "Average"
threshold = "${local.thresholds["CPUUtilizationThreshold"]}"
alarm_description = "Average database CPU utilization over last 10 minutes too high"
alarm_actions = ["${aws_sns_topic.default.arn}"]
ok_actions = ["${aws_sns_topic.default.arn}"]
dimensions {
DBInstanceIdentifier = "${var.db_instance_id}"
}
}
resource "aws_cloudwatch_metric_alarm" "cpu_credit_balance_too_low" {
alarm_name = "cpu_credit_balance_too_low"
comparison_operator = "LessThanThreshold"
evaluation_periods = "1"
metric_name = "CPUCreditBalance"
namespace = "AWS/RDS"
period = "600"
statistic = "Average"
threshold = "${local.thresholds["CPUCreditBalanceThreshold"]}"
alarm_description = "Average database CPU credit balance over last 10 minutes too low, expect a significant performance drop soon"
alarm_actions = ["${aws_sns_topic.default.arn}"]
ok_actions = ["${aws_sns_topic.default.arn}"]
dimensions {
DBInstanceIdentifier = "${var.db_instance_id}"
}
}
resource "aws_cloudwatch_metric_alarm" "disk_queue_depth_too_high" {
alarm_name = "disk_queue_depth_too_high"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = "1"
metric_name = "DiskQueueDepth"
namespace = "AWS/RDS"
period = "600"
statistic = "Average"
threshold = "${local.thresholds["DiskQueueDepthThreshold"]}"
alarm_description = "Average database disk queue depth over last 10 minutes too high, performance may suffer"
alarm_actions = ["${aws_sns_topic.default.arn}"]
ok_actions = ["${aws_sns_topic.default.arn}"]
dimensions {
DBInstanceIdentifier = "${var.db_instance_id}"
}
}
resource "aws_cloudwatch_metric_alarm" "freeable_memory_too_low" {
alarm_name = "freeable_memory_too_low"
comparison_operator = "LessThanThreshold"
evaluation_periods = "1"
metric_name = "FreeableMemory"
namespace = "AWS/RDS"
period = "600"
statistic = "Average"
threshold = "${local.thresholds["FreeableMemoryThreshold"]}"
alarm_description = "Average database freeable memory over last 10 minutes too low, performance may suffer"
alarm_actions = ["${aws_sns_topic.default.arn}"]
ok_actions = ["${aws_sns_topic.default.arn}"]
dimensions {
DBInstanceIdentifier = "${var.db_instance_id}"
}
}
resource "aws_cloudwatch_metric_alarm" "free_storage_space_too_low" {
alarm_name = "free_storage_space_threshold"
comparison_operator = "LessThanThreshold"
evaluation_periods = "1"
metric_name = "FreeStorageSpace"
namespace = "AWS/RDS"
period = "600"
statistic = "Average"
threshold = "${local.thresholds["FreeStorageSpaceThreshold"]}"
alarm_description = "Average database free storage space over last 10 minutes too low"
alarm_actions = ["${aws_sns_topic.default.arn}"]
ok_actions = ["${aws_sns_topic.default.arn}"]
dimensions {
DBInstanceIdentifier = "${var.db_instance_id}"
}
}
resource "aws_cloudwatch_metric_alarm" "swap_usage_too_high" {
alarm_name = "swap_usage_too_high"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = "1"
metric_name = "SwapUsage"
namespace = "AWS/RDS"
period = "600"
statistic = "Average"
threshold = "${local.thresholds["SwapUsageThreshold"]}"
alarm_description = "Average database swap usage over last 10 minutes too high, performance may suffer"
alarm_actions = ["${aws_sns_topic.default.arn}"]
ok_actions = ["${aws_sns_topic.default.arn}"]
dimensions {
DBInstanceIdentifier = "${var.db_instance_id}"
}
}