File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
infra/terraform/hash/postgres Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments