Skip to content

Instantly share code, notes, and snippets.

@tom-butler
Last active December 12, 2017 22:31
Show Gist options
  • Save tom-butler/7a9aa11628bb060301a30546df5ee541 to your computer and use it in GitHub Desktop.
Save tom-butler/7a9aa11628bb060301a30546df5ee541 to your computer and use it in GitHub Desktop.
send docker logs to cloudwatch
Copy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogStreams"
],
"Resource": [
"arn:aws:logs:*:*:*"
]
}
]
}
version: '2'
services:
grafana:
image: geoscienceaustralia/autobots-grafana:latest
ports:
- 3000
logging:
driver: awslogs
options:
awslogs-region: "ap-southeast-2"
awslogs-group: "grafana"
...
# Forward grafana logs to docker log collector
RUN ln -sf /dev/stdout /var/log/grafana.log
...
resource "aws_cloudwatch_log_group" "grafana" {
name = "grafana"
retention_in_days = "30"
}
@tom-butler
Copy link
Author

Built for ECS, but should work on other environments.

  • Create a symlink from the log to /dev/stdout
  • Configure awslogs driver
  • Create a log group to store the logs
  • Add the policy to your instance profile to ensure the instances can write to cloudwatch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment