Collecting container logs with Amazon ECS logs collector
If you are unsure how to collect all of the various logs on your container instances,
you can use the Amazon ECS logs collector. It is available on GitHub for both Linux
-
Amazon Linux
-
Red Hat Enterprise Linux 7
-
Debian 8
-
Ubuntu 14.04
-
Ubuntu 16.04
-
Ubuntu 18.04
-
Windows Server 2016
Note
To download and run the Amazon ECS logs collector for Linux
-
Connect to your container instance.
-
Download the Amazon ECS logs collector script.
curl -O https://raw.githubusercontent.com/awslabs/ecs-logs-collector/master/ecs-logs-collector.sh
-
Run the script to collect the logs and create the archive.
Note
To enable the debug mode for the Docker daemon and the Amazon ECS container agent, add the
--mode=enable-debug
option to the following command. This might restart the Docker daemon, which kills all containers that are running on the instance. Consider draining the container instance and moving any important tasks to other container instances before enabling debug mode. For more information, see Draining Amazon ECS container instances.[ec2-user ~]$
sudo bash ./ecs-logs-collector.sh
Important
We recommend that you edit the logs and remove all sensitive data from the files. You
can search for known data, and also search for environment variables such as AWS_ACCESS_KEY_ID
,
AWS_SECRET_ACCESS_KEY
, and AWS_SESSION_TOKEN
in the file.
After you have run the script, you can examine the collected logs in the
collect
folder that the script created. The
collect.tgz
file is a compressed archive of all of the logs,
which you can share with Amazon Web Services Support for diagnostic help.
To download and run the Amazon ECS logs collector for Windows
-
Connect to your container instance. For more information, see Connecting to Your Windows Instance in the Amazon EC2 User Guide.
-
Download the Amazon ECS logs collector script using PowerShell.
Invoke-WebRequest -OutFile ecs-logs-collector.ps1 https://raw.githubusercontent.com/awslabs/aws-ecs-logs-collector-for-windows/master/ecs-logs-collector.ps1
-
Run the script to collect the logs and create the archive.
Note
To enable the debug mode for the Docker daemon and the Amazon ECS container agent, add the
-RunMode debug
option to the following command. This restarts the Docker daemon, which kills all containers that are running on the instance. Consider draining the container instance and moving any important tasks to other container instances before enabling debug mode. For more information, see Draining Amazon ECS container instances..\ecs-logs-collector.ps1
Important
We recommend that you edit the logs and remove all sensitive data from the files. You
can search for known data, and also search for environment variables such as AWS_ACCESS_KEY_ID
,
AWS_SECRET_ACCESS_KEY
, and AWS_SESSION_TOKEN
in the file.
After you have run the script, you can examine the collected logs in the
collect
folder that the script created. The
collect.tgz
file is a compressed archive of all of the logs,
which you can share with Amazon Support for diagnostic help.