Skip to content

Commit 96f50cc

Browse files
committed
feat: add CloudWatch alarms for RDS CPU, connections, and storage monitoring
1 parent fbf2307 commit 96f50cc

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

monitoring.tf

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# CloudWatch Alarms for RDS
2+
# Monitors critical database metrics
3+
4+
resource "aws_cloudwatch_metric_alarm" "rds_cpu" {
5+
alarm_name = "rds-cpu-utilization-high"
6+
comparison_operator = "GreaterThanThreshold"
7+
evaluation_periods = 3
8+
metric_name = "CPUUtilization"
9+
namespace = "AWS/RDS"
10+
period = 300
11+
statistic = "Average"
12+
threshold = 80
13+
alarm_description = "RDS CPU utilization above 80%"
14+
}
15+
16+
resource "aws_cloudwatch_metric_alarm" "rds_connections" {
17+
alarm_name = "rds-connections-high"
18+
comparison_operator = "GreaterThanThreshold"
19+
evaluation_periods = 2
20+
metric_name = "DatabaseConnections"
21+
namespace = "AWS/RDS"
22+
period = 300
23+
statistic = "Average"
24+
threshold = 100
25+
alarm_description = "RDS connections exceeding threshold"
26+
}
27+
28+
resource "aws_cloudwatch_metric_alarm" "rds_storage" {
29+
alarm_name = "rds-free-storage-low"
30+
comparison_operator = "LessThanThreshold"
31+
evaluation_periods = 2
32+
metric_name = "FreeStorageSpace"
33+
namespace = "AWS/RDS"
34+
period = 300
35+
statistic = "Average"
36+
threshold = 5368709120 # 5GB in bytes
37+
alarm_description = "RDS free storage below 5GB"
38+
}

0 commit comments

Comments
 (0)