Skip to content
This repository was archived by the owner on Dec 29, 2025. It is now read-only.

Commit 570a5bf

Browse files
committed
Fix CloudWatch Agent dimensions and alarms
1 parent faf04c3 commit 570a5bf

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

project/TASKS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
- [x] Give the instance profile permission to access the filesystem, if needed
3232
- [x] Update the EC2 instance terraform to mount the EFS filesystem
3333
- [x] Update env.example to include the correct mount path for EFS for LETS_ENCRYPT_CERTS_DIR
34-
- [ ] The CloudWatch Agent configuration in user-data.sh is wrong.
35-
- [ ] The mem_used_percent metric is appearing with a host dimension, with a name like "ip-10-0-1-200". We want "instance id" as the sole dimension.
36-
- [ ] The disk_used_percent metric is appearing with device, fstype, host, and path dimensions. We want "instance id" and "path" as the two dimensions.
37-
- [ ] Update the CloudWatch alarms accordingly; they are pointing at nonexistent metrics right now.
34+
- [x] The CloudWatch Agent configuration in user-data.sh is wrong.
35+
- [x] The mem_used_percent metric is appearing with a host dimension, with a name like "ip-10-0-1-200". We want "instance id" as the sole dimension.
36+
- [x] The disk_used_percent metric is appearing with device, fstype, host, and path dimensions. We want "instance id" and "path" as the two dimensions.
37+
- [x] Update the CloudWatch alarms accordingly; they are pointing at nonexistent metrics right now.

terraform/main.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,6 @@ resource "aws_cloudwatch_metric_alarm" "disk_usage" {
343343

344344
dimensions = {
345345
InstanceId = aws_instance.api.id
346-
device = "/dev/root"
347-
fstype = "ext4"
348346
path = "/"
349347
}
350348

terraform/user-data.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,14 @@ cat > /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json << EOF
4848
"/"
4949
]
5050
}
51-
}
51+
},
52+
"append_dimensions": {
53+
"InstanceId": "${aws:InstanceId}"
54+
},
55+
"aggregation_dimensions": [
56+
["InstanceId"],
57+
["InstanceId", "path"]
58+
]
5259
}
5360
}
5461
EOF

0 commit comments

Comments
 (0)