Skip to content

Commit f5288c1

Browse files
authored
SRE-80: Add CPUUtilization CloudWatch alert for RDS (#8003)
1 parent 20dcaeb commit f5288c1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

infra/terraform/hash/postgres/alerts.tf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,32 @@ resource "aws_cloudwatch_metric_alarm" "rds_free_storage_space" {
4747
Purpose = "Alert when RDS free storage space is critically low"
4848
}
4949
}
50+
51+
# CloudWatch Alarm for RDS CPU utilization
52+
resource "aws_cloudwatch_metric_alarm" "rds_cpu_utilization_high" {
53+
alarm_name = "${var.prefix}-rds-cpu-utilization-high"
54+
alarm_description = "WARNING: RDS instance ${aws_db_instance.postgres.identifier} has high CPU utilization."
55+
56+
# RDS CPU metrics
57+
metric_name = "CPUUtilization"
58+
namespace = "AWS/RDS"
59+
statistic = "Average"
60+
period = 300 # 5 minutes
61+
evaluation_periods = 2 # Must be high for 10 minutes total
62+
threshold = 80 # 80%
63+
comparison_operator = "GreaterThanThreshold"
64+
treat_missing_data = "notBreaching"
65+
66+
dimensions = {
67+
DBInstanceIdentifier = aws_db_instance.postgres.identifier
68+
}
69+
70+
alarm_actions = [aws_sns_topic.database_alerts.arn]
71+
ok_actions = [aws_sns_topic.database_alerts.arn]
72+
73+
tags = {
74+
Name = "${var.prefix}-rds-cpu-utilization-high-alarm"
75+
Severity = "WARNING"
76+
Purpose = "Alert when RDS CPU utilization is consistently high"
77+
}
78+
}

0 commit comments

Comments
 (0)