Last updated
Last updated
This page was generated from content adapted from the
Note
This configuration only handles the logging of the execute-command
session. It doesn't affect logging of your application.
Note
Because the execute-command
API action contains only task and cluster resources in a request, only cluster and task tags are evaluated.
Important Amazon ECS provides the Amazon ECS logs collection tool. You can use it to collect logs from your external instances for troubleshooting purposes. For more information, see .
Important Stopped tasks only appear in the Amazon ECS console, AWS CLI, and AWS SDKs for at least 1 hour after the task stops. After that, the details of the stopped task expire and aren't available in Amazon ECS. Amazon ECS also sends task state change events to Amazon EventBridge. You can't view events in EventBridge. Instead, you create rules to send the events to other persistent storage such as Amazon CloudWatch Logs. You can use the storage to view your stopped task details after it has expired from view in the Amazon ECS console. For more information, see . For a sample EventBridge configuration to archive Amazon ECS events to Amazon CloudWatch Logs, see on the GitHub website.
Note When using Terraform, the following error may be returned.
Note Task-level CPU and memory parameters are ignored for Windows containers.
Note The command below is piped through the python -mjson.tool for greater readability.
Important This procedure is written for the Amazon ECS-optimized Amazon Linux AMI. For other operating systems, see and in the Docker documentation.
Note If you are not sure how to collect all of the logs on your container instances, you can use the Amazon ECS logs collector. For more information, see .
Note The source code for the Amazon ECS logs collector is available on GitHub for both and . We encourage you to submit pull requests for changes that you would like to have included. However, Amazon Web Services doesn't currently support running modified copies of this software.
Important Your container instance must have an IAM role that allows access to Amazon ECS in order to reach the introspection API. For more information, see .
Note
Docker logs are only available on the container instance if you are using the default json
log driver. If you have configured your tasks to use the awslogs
log driver, then your container logs are available in CloudWatch Logs. For more information, see .
Note Besides the failure scenarios described here, APIs can also fail due to exceptions, resulting in error responses. For a list of such exceptions, see .