Al usar AWS re:Post, aceptas las AWS re:Post Términos de uso

How do I use the ECS logs collector script to collect logs from my Amazon ECS container instance?

3 minutos de lectura
0

I want to collect logs from my Amazon Elastic Container Service (Amazon ECS) to troubleshoot my environment.

Short description

Use the Amazon ECS logs collector script to collect general operating system (OS), Docker, and Amazon ECS container agent logs. The script compresses and archives the logs into a single file that you can share to troubleshoot an issue.

You can also use the AWSSupport-CollectECSInstanceLogs AWS Systems Manager runbook to collect logs from your ECS instance, and upload the logs to an Amazon Simple Storage Service (Amazon S3) bucket. In the LogDestination input parameter, provide the location of the Amazon S3 bucket.

Note: AWSSupport-CollectECSInstanceLogs doesn't support debug mode. For more information, see Run an automated operation powered by Systems Manager Automation.

Resolution

Download and run the Amazon ECS logs collector

For instructions on how to connect to your container instance, see Connect to your container instance using SSH. For instructions on how to download and run the logs collector for Linux and Windows, see Collecting container logs with Amazon ECS logs collector.

For Linux, you must use curl. To confirm that you installed curl, run the following command:

curl --version

The command output is similar to the following example:

curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3

Note: If the command doesn't return the expected results, then install the curl package.

After you run the script, you can review the collected logs in the collect folder that the script created. For Linux, the compressed archive of all the logs is collect-i-ffffffffffffffffff-YYYYMMDDHHmm.tgz. For Windows, it's the collect.tgz file.

Run the Amazon ECS logs collector in debug mode

Debug mode lets you troubleshoot complex issues in your ECS environment that standard log details might not be able to.

To turn on debug logging for the Docker daemon and Amazon ECS container agent, use --mode=enable-debug for Linux and -RunMode debug for Windows.

Note: The script restarts the Docker daemon and Amazon ECS agent and terminates all containers that are running on the instance. Before you run the following command, drain the container instance and move important tasks to other container instances.

Linux

Debug mode works only on Amazon Linux OS and Systemd init based systems.

When you run the script, run the following command:

[ec2-user ~]$ sudo bash ./ecs-logs-collector.sh --mode=enable-debug

Windows

When you run the script, use Windows PowerShell with administrator permissions to run the following command:

.\ecs-logs-collector.ps1 -RunMode debug
OFICIAL DE AWS
OFICIAL DE AWSActualizada hace 3 meses