-
Notifications
You must be signed in to change notification settings - Fork 48
/
alarms.tf
100 lines (90 loc) · 3.99 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
resource "aws_cloudwatch_metric_alarm" "alarm_rds_DatabaseConnections_writer" {
count = var.enabled && var.cw_alarms ? 1 : 0
alarm_name = "${aws_rds_cluster.default[0].id}-alarm-rds-writer-DatabaseConnections"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = var.cw_eval_period_connections
metric_name = "DatabaseConnections"
namespace = "AWS/RDS"
period = "60"
statistic = "Sum"
threshold = var.cw_max_conns
alarm_description = "RDS Maximum connection Alarm for ${aws_rds_cluster.default[0].id} writer"
alarm_actions = [var.cw_sns_topic]
ok_actions = [var.cw_sns_topic]
dimensions = {
DBClusterIdentifier = aws_rds_cluster.default[0].id
Role = "WRITER"
}
}
resource "aws_cloudwatch_metric_alarm" "alarm_rds_DatabaseConnections_reader" {
count = var.enabled && var.cw_alarms && var.replica_count > 0 ? 1 : 0
alarm_name = "${aws_rds_cluster.default[0].id}-alarm-rds-reader-DatabaseConnections"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = var.cw_eval_period_connections
metric_name = "DatabaseConnections"
namespace = "AWS/RDS"
period = "60"
statistic = "Maximum"
threshold = var.cw_max_conns
alarm_description = "RDS Maximum connection Alarm for ${aws_rds_cluster.default[0].id} reader(s)"
alarm_actions = [var.cw_sns_topic]
ok_actions = [var.cw_sns_topic]
dimensions = {
DBClusterIdentifier = aws_rds_cluster.default[0].id
Role = "READER"
}
}
resource "aws_cloudwatch_metric_alarm" "alarm_rds_CPU_writer" {
count = var.enabled && var.cw_alarms ? 1 : 0
alarm_name = "${aws_rds_cluster.default[0].id}-alarm-rds-writer-CPU"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = var.cw_eval_period_cpu
metric_name = "CPUUtilization"
namespace = "AWS/RDS"
period = "60"
statistic = "Maximum"
threshold = var.cw_max_cpu
alarm_description = "RDS CPU Alarm for ${aws_rds_cluster.default[0].id} writer"
alarm_actions = [var.cw_sns_topic]
ok_actions = [var.cw_sns_topic]
dimensions = {
DBClusterIdentifier = aws_rds_cluster.default[0].id
Role = "WRITER"
}
}
resource "aws_cloudwatch_metric_alarm" "alarm_rds_CPU_reader" {
count = var.enabled && var.cw_alarms && var.replica_count > 0 ? 1 : 0
alarm_name = "${aws_rds_cluster.default[0].id}-alarm-rds-reader-CPU"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = var.cw_eval_period_cpu
metric_name = "CPUUtilization"
namespace = "AWS/RDS"
period = "60"
statistic = "Maximum"
threshold = var.cw_max_cpu
alarm_description = "RDS CPU Alarm for ${aws_rds_cluster.default[0].id} reader(s)"
alarm_actions = [var.cw_sns_topic]
ok_actions = [var.cw_sns_topic]
dimensions = {
DBClusterIdentifier = aws_rds_cluster.default[0].id
Role = "READER"
}
}
resource "aws_cloudwatch_metric_alarm" "alarm_rds_replica_lag" {
count = var.enabled && var.cw_alarms && var.replica_count > 0 ? 1 : 0
alarm_name = "${aws_rds_cluster.default[0].id}-alarm-rds-reader-AuroraReplicaLag"
comparison_operator = "GreaterThanOrEqualToThreshold"
evaluation_periods = var.cw_eval_period_replica_lag
metric_name = "AuroraReplicaLag"
namespace = "AWS/RDS"
period = "60"
statistic = "Maximum"
threshold = var.cw_max_replica_lag
alarm_description = "RDS CPU Alarm for ${aws_rds_cluster.default[0].id}"
alarm_actions = [var.cw_sns_topic]
ok_actions = [var.cw_sns_topic]
dimensions = {
DBClusterIdentifier = aws_rds_cluster.default[0].id
Role = "READER"
}
}