This example shows how to run the AWS CloudWatch logs agent in a Docker container in order to send logs from a local environment to AWS.
This is useful if you are generating a lot of logs locally and want to use a tool like CloudWatch Logs Insights to query those logs.
The example configuration monitors the /logs
directory within the container and sends everything in that directory to CloudWatch.
docker
docker-compose
- Create the credentials file:
$ cp logger/aws.credentials.template logger/aws.credentials
- Add valid credentials to the
AmazonCloudWatchAgent
profile inlogger/aws.credentials
. - Start the containers:
$ ./go.sh
- From within the
awscli
container, create a log file entry:
ec2-user@2b4fa1d76296:/mounted-files$ echo "hello world" > /logs/test.log
$ docker-compose down