- Newest
- Most votes
- Most comments
It sounds like you've taken some good initial steps to set up CloudWatch logging for your EC2 instance, but there may be a few additional steps needed to get the logs appearing in CloudWatch. Here's what you can do to troubleshoot and ensure proper configuration:
-
Install the CloudWatch agent: For Ubuntu, you need to download and install the CloudWatch agent package. You can do this by running these commands:
For x86-64 architecture: wget https://amazoncloudwatch-agent.s3.amazonaws.com/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
For ARM64 architecture: wget https://amazoncloudwatch-agent.s3.amazonaws.com/ubuntu/arm64/latest/amazon-cloudwatch-agent.deb sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
-
Configure the CloudWatch agent: After installation, you need to create a configuration file that specifies which logs to collect. You can do this manually or use the configuration wizard:
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
-
Start the CloudWatch agent: Once configured, start the agent with this command:
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/path/to/your/config-file.json
-
Check agent status: Verify the agent is running correctly:
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status
-
Verify log groups: Check if the log groups are created in the CloudWatch console. The log group names should match what you specified in your configuration.
-
Check instance permissions: Ensure your EC2 instance role has the necessary permissions to send logs to CloudWatch.
If you've followed these steps and still don't see logs, check the agent's own logs for any errors:
/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log
Remember, it may take a few minutes for logs to appear in CloudWatch after configuration. If issues persist, double-check your configuration file and ensure the specified log files exist on your instance.
Sources
How to setup cloudwatch agent on EC2 instance running with ubuntu | AWS re:Post
How to update clodwatch agent config on a Ec2 | AWS re:Post

Thanks for the answer, howerer how can I find the file configuration in the instance if I used the online console wizard?