In a container environment, it is important to monitor the host for any host-level issues and/or impacting behaviour. While Container Insights allows the collection of host-level metrics using the CloudWatch agent in daemon mode, logs from the host such as Docker daemon and ECS agent logs. However, instances may sometimes be terminated, or not be configured to allow access, hence it would be impossible in these cases to access the logs and triage the issue. There is a need for an automated log collection for ECS Container Insights.
Description of changes
This pull request introduces the capability to deploy fluent-bit as an additional daemonset to collect the logs from the host and populate them in CloudWatch in the /aws/ecs/containerinsights/${CLUSTER_NAME}/instance-logs log group. The below logs are collected:
ECS agent logs
ECS audit logs
ECS init logs
ECS volume plugin logs
Docker daemon logs
Containerd logs
System log
Kernel log (i.e. dmesg)
/var/log/secure (Not collected on systems with rsyslog not installed such as AL2023. However these events are recorded in the system log)
License
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Tests
This PR does not modify the existing CloudWatch agent CFN stack and configurations, hence existing users using these stacks would experience no changes. Fluent-bit is provided as an additional configuration and CFN stack (for existing Container Insights users wanting to upgrade, or for those who simply want to deploy only one option), and there is a third stack which can deploy both CloudWatch agent and Fluent-Bit in a single stack (for new users).
The solution is confirmed to work on the below Operating Systems:
Amazon Linux 2
Amazon Linux 2023
Ubuntu 20.04
Ubuntu 22.04
Ubuntu 24.04
Red Hat Enterprise Linux (RHEL) 8
Red Hat Enterprise Linux (RHEL) 9
CentOS Stream 9
Requirements
Before committing the code, please verify the following:
If this commit includes changes to existing sample configurations, you acknowledge that you have confirmed this will not impact existing customer behavior.
If not necessary, consider creating a new sample configuration for this change.
Description of the issue
In a container environment, it is important to monitor the host for any host-level issues and/or impacting behaviour. While Container Insights allows the collection of host-level metrics using the CloudWatch agent in daemon mode, logs from the host such as Docker daemon and ECS agent logs. However, instances may sometimes be terminated, or not be configured to allow access, hence it would be impossible in these cases to access the logs and triage the issue. There is a need for an automated log collection for ECS Container Insights.
Description of changes
This pull request introduces the capability to deploy fluent-bit as an additional daemonset to collect the logs from the host and populate them in CloudWatch in the
/aws/ecs/containerinsights/${CLUSTER_NAME}/instance-logs
log group. The below logs are collected:License
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Tests
This PR does not modify the existing CloudWatch agent CFN stack and configurations, hence existing users using these stacks would experience no changes. Fluent-bit is provided as an additional configuration and CFN stack (for existing Container Insights users wanting to upgrade, or for those who simply want to deploy only one option), and there is a third stack which can deploy both CloudWatch agent and Fluent-Bit in a single stack (for new users).
The solution is confirmed to work on the below Operating Systems:
Requirements
Before committing the code, please verify the following: