Before your containers can send logs to CloudWatch, you must specify the awslogs
log driver for containers in your task definition. For more information about the log parameters, see Storage and logging
The task definition JSON that follows has a logConfiguration
object specified for each container. One is for the WordPress container that sends logs to a log group called awslogs-wordpress
. The other is for a MySQL container that sends logs to a log group that's called awslogs-mysql
. Both containers use the awslogs-example
log stream prefix.
{
"containerDefinitions": [
{
"name": "wordpress",
"links": [
"mysql"
],
"image": "public.ecr.aws/docker/library/wordpress:latest",
"essential": true,
"portMappings": [
{
"containerPort": 80,
"hostPort": 80
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-create-group": "true",
"awslogs-group": "awslogs-wordpress
",
"awslogs-region": "us-west-2
",
"awslogs-stream-prefix": "awslogs-example
"
}
},
"memory": 500,
"cpu": 10
},
{
"environment": [
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "password"
}
],
"name": "mysql",
"image": "public.ecr.aws/docker/library/mysql:latest",
"cpu": 10,
"memory": 500,
"essential": true,
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-create-group": "true",
"awslogs-group": "awslogs-mysql
",
"awslogs-region": "us-west-2
",
"awslogs-stream-prefix": "awslogs-example
",
"mode": "non-blocking",
"max-buffer-size": "25m"
}
}
}
],
"family": "awslogs-example"
}
Next steps
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4