I want to configure a log driver for my Amazon Elastic Container Service (Amazon ECS) tasks on AWS Fargate.
Short description
When you create a task definition for AWS Fargate, you can have Amazon ECS auto-configure your Amazon CloudWatch logs. This option creates a log group on your behalf and uses the task definition family name with ecs as the prefix.
Resolution
To configure your log driver to use the log group auto-configuration option, complete the following steps:
- Open the Amazon ECS console.
- In the navigation pane, choose Task definitions, and then choose Create new Task Definition.
- On the Create new task definition page, for Task definition configuration, enter a name for the task definition family.
- Under Infrastructure requirements, for Launch type, choose AWS Fargate.
- Under Container, for Logging, select Use log collection. Then, enter the following information:
To configure your tasks to use awslogs log driver to send logs to CloudWatch, choose Amazon CloudWatch.
For the awslogs-group key, leave the value as it is. If the field is empty, then enter a value for your group.
For the awslogs-region key, leave the value as it is. If the field is empty, then enter a value for your AWS Region.
For the awslogs-stream-prefix key, leave the value as it is. If the field is empty, then enter a value for your stream.
If the log group doesn't exist, then set the awslogs-create-group parameter to true. For the task execution role, use the logs:CreateLogGroup action.
Note: Based on your use case, you can define other parameters. For more information, see Example Amazon ECS task definition: Route logs to CloudWatch.
- Choose Create.
Related information
Fargate launch type
Amazon ECS task execution IAM role