How do I configure a log driver for my Amazon ECS tasks on AWS Fargate?

Last updated: 2020-11-20

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 have the option to allow Amazon ECS to auto-configure your Amazon CloudWatch logs. This option creates a log group on your behalf using the task definition family name with ecs as the prefix.

Resolution

Use the log group auto-configuration option to configure your log driver:
  1. Open the Amazon ECS console.
  2. From the navigation pane, choose Task Definitions, and then choose Create new Task Definition.
  3. In the Select launch type compatibility section, choose FARGATE, and then choose Next Step.
  4. In the Configure task and container definitions section, for Task Definition Name, enter a name for your task definition.
  5. In the Container Definitions, choose Add container.
  6. Fill out the required fields based on your container requirements.
  7. In the STORAGE AND LOGGING section, for Log configuration, choose one of the following options:
    If you want to accept the default values of awslogs-group, awslogs-region, and awslogs-stream-prefix, select the Auto-configure CloudWatch Logs check box. Then, skip to step 8.
    If you want a custom log group and stream, clear the Auto-configure CloudWatch Logs check box. Then, complete the following steps:
    For Log driver, select awslogs. If the log group doesn't exist, set the awslogs-create-group parameter and use the required logs:CreateLogGroup action for the task execution role.
    (Required) For the awslogs-group key, leave the auto-populated value in place, or enter a value for your group if the text box is empty.
    (Required) For the awslogs-region key, leave the auto-populated value in place, or enter a value for your AWS Region if the text box is empty.
    (Required) For the awslogs-stream-prefix key, leave the auto-populated value in place, or enter a value for your stream if the text box is empty. You can define other parameters based on your use case. For more information, see Specifying a log configuration in your task definition.
  8. Choose Add.
  9. Fill out the remaining fields in the task definition wizard, and then choose Create.

  10. Did this article help?


    Do you need billing or technical support?