Code Monkey home page Code Monkey logo

amazon-ecs-logs-collector's Introduction

ECS Logs Collector

This project was created to collect Amazon ECS log files and Operating System log files for troubleshooting Amazon ECS customer support cases.

The following functions are supported:

  • Collect Operating System logs
  • Collect Operating System settings
  • Collect Docker logs
  • Collect Amazon ECS agent Logs
  • Enable debug mode for Docker and the Amazon ECS agent (only available for Systemd init systems and Amazon Linux)
  • Create a tar zip file in the same folder as the script

Usage

Run this project as the root user:

curl -O https://raw.githubusercontent.com/aws/amazon-ecs-logs-collector/master/ecs-logs-collector.sh
bash ecs-logs-collector.sh

Confirm if the tarball file was successfully created (it can be .tgz or .tar.gz)

# ls collect*
collect-i-ffffffffffffffffff-YYYYMMDDHHmm.tgz

collect:
i-ffffffffffffffffff

Retrieving the logs

Download the tarball using your favourite Secure Copy tool.

Example output

The project can be used in normal or enable-debug mode. Enable debug is only available for Systemd init systems and Amazon Linux.

# bash ecs-logs-collector.sh --help
USAGE: ./ecs-logs-collector.sh [--mode=[brief|enable-debug]]
       ./ecs-logs-collector.sh --help

OPTIONS:
     --mode  Sets the desired mode of the script. For more information,
             see the MODES section.
     --help  Show this help message.

MODES:
     brief         Gathers basic operating system, Docker daemon, and Amazon
                   ECS Container Agent logs. This is the default mode.
     enable-debug  Enables debug mode for the Docker daemon and the Amazon
                   ECS Container Agent. Only supported on Systemd init systems
                   and Amazon Linux.

Example output in normal mode

The following output shows this project running in normal mode.

# bash ecs-logs-collector.sh
Trying to check if the script is running as root ... ok
Trying to resolve instance-id ... ok
Trying to collect system information ... ok
Trying to check disk space usage ... ok
Trying to collect common operating system logs ... ok
Trying to collect kernel logs ... ok
Trying to get mount points and volume information ... ok
Trying to check SELinux status ... ok
Trying to get iptables list ... ok
Trying to detect installed packages ... ok
Trying to detect active system services list ... ok
Trying to gather Docker daemon information ... ok
Trying to inspect all Docker containers ... ok
Trying to collect Docker and containerd daemon logs ... ok
Trying to collect Docker systemd unit file ... ok
Trying to collect containerd systemd unit file ... ok
Trying to collect Docker sysconfig ... ok
Trying to collect Docker storage sysconfig ... ok
Trying to collect Docker daemon.json ... ok
Trying to collect Amazon ECS Container Agent logs ... ok
Trying to collect Amazon ECS Container Agent state and config ... ok
Trying to collect Amazon ECS Container Agent engine data ... ok
Trying to get open files list ... ok
Trying to collect /etc/os-release ... ok
Trying to get uname kernel info ... ok
Trying to get dmidecode info ... ok
Trying to get lsmod info ... ok
Trying to collect systemd slice info ... ok
Trying to get veth info ... ok
Trying to get gpu info ... ok
Trying to archive gathered log information ... ok

Example output in enable-debug mode

The following output shows this project enabling debug mode for the Docker daemon and the Amazon ECS Container Agent. This mode only works on Amazon Linux OS and Systemd init systems such as RHEL 7 and Ubuntu 16.04. Note that enable-debug mode restarts Docker and the Amazon ECS agent.

# bash ecs-logs-collector.sh --mode=enable-debug
Trying to check if the script is running as root ... ok
Trying to collect system information ... ok
Trying to enable debug mode for the Docker daemon ... ok
Trying to restart Docker daemon to enable debug mode ... ok
Trying to enable debug mode for the Amazon ECS Container Agent ... ok
Trying to restart the Amazon ECS Container Agent to enable debug mode ... ok

Contributing

Please create a new GitHub issue for any feature requests, bugs, or documentation improvements.

Where possible, submit a pull request for the change.

License

Copyright 2011-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at

http://aws.amazon.com/apache2.0/

or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

amazon-ecs-logs-collector's People

Contributors

aaithal avatar chienhanlin avatar dsalamancams avatar fenxiong avatar fierlion avatar fjromerom avatar hprudent avatar hugoprudente avatar jahkeup avatar jhaynes avatar mfortin avatar mmssantos avatar nithu0115 avatar nitishtw avatar ovalba avatar rohanmangal avatar sharuzzaman avatar singholt avatar slacksec avatar sparrc avatar unakarlsen avatar willhoule avatar witsoej avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amazon-ecs-logs-collector's Issues

Script didnt generate tarball..

Summary

ecs-logs-collector script did not create tarball.

Description

Script Documentation details require update with right tarball location.

Expected Behavior

collect.tgz file is exepcted in the path where script is executed.

Observed Behavior

tarball with instancename.tgz is observed in collect folder.

Below are additional details..

Trying to collect Docker daemon logs ... ok
Trying to collect Amazon ECS Container Agent logs ... ok
Trying to collect Amazon ECS Container Agent state and config ... ok
Trying to collect Amazon ECS Container Agent engine data ... ok
Trying to collect Amazon ECS init logs ... ok
Trying to check if the script is running as root ... ok
Trying to resolve instance-id ... ecs-logs-collector.sh: line 175: ./collect/i-0cf25496945da6295/i-0cf25496945da6295/system/instance-id.txt: No such file or directory
ok
Trying to collect system information ... ok
Trying to enable debug mode for the Docker daemon ... Trying to restart Docker daemon to enable debug mode ... Stopping docker: [ OK ]
Starting docker: . [ OK ]
ok
Trying to enable debug mode for the Amazon ECS Container Agent ... Trying to restart the Amazon ECS Container Agent to enable debug mode ... stop: Job has already been stopped: ecs
ecs start/running, process 3087
ok
Trying to archive gathered log information ... ok

ls

collect ecs-logs-collector.sh

The script is generating tarball with instance id in the collect folder. Please update the Documentation page.

Trying to archive gathered log information ... + local tar_bin
++ which tar

  • tar_bin=/bin/tar
  • '[' -z /bin/tar ']'
  • cd .
  • /bin/tar -czf ./collect/i-0cf25496945da6295.tgz ./collect/i-0cf25496945da6295
  • ok
  • echo ok

log collection can wait indefinitely

Summary

If start ecs fails, the log collector can hang indefinitely. We should change this to retry, and also report logs even if this command fails.

Addition of disable-debug mode to ECS Logs Collector

Summary

Addition of disable-debug mode to ECS Logs Collector will help in disabling debug mode previously enabled for the Docker daemon and the Amazon ECS Container Agent.

Description

When troubleshooting issues in Amazon ECS, it's often necessary to enable debug logging for the Docker daemon and the Amazon ECS Container Agent to gather detailed logs. However, once the troubleshooting is completed, it's crucial to disable the debug mode as the verbose logging can consume a significant amount of storage space and disk I/O operations, leading to unnecessary resource consumption and potential performance issues.

The proposed feature is to add a "disable-debug" mode to the ECS Logs Collector, which would allow users to disable the debug logging for the Docker daemon and the Amazon ECS Container Agent with a single command or configuration setting. This would streamline the process of reverting to normal logging levels after troubleshooting, ensuring efficient resource utilization and preventing potential issues caused by excessive logging.

Expected Behavior

After enabling the "disable-debug" mode, the Docker daemon and the Amazon ECS Container Agent should be reverted to their default logging levels, reducing the storage space and disk I/O operations consumed by debug logging.

Observed Behavior

Currently, there is no built-in mechanism or convenient way to disable the debug logging for the Docker daemon and the Amazon ECS Container Agent after troubleshooting. Users either forget or have to manually modify the configuration files or execute multiple commands to revert to the default logging levels, which can be time-consuming and error-prone.

Benefits

  • Improved resource efficiency by reducing unnecessary storage space and disk I/O operations consumed by debug logging.
  • Streamlined process for disabling debug logging after troubleshooting, reducing the risk of human error and saving time.
  • Potential performance improvements by eliminating the overhead of excessive logging.
  • Increased operational efficiency and ease of use for Amazon ECS users.

Proposed Implementation Approach

Proposal is to extend the existing ECS Logs Collector functionality to include a "disable-debug" as third supported mode, This can be achieved by:

  1. Adding a new command-line mode (e.g., `--mode=disable-debug) to the ECS Logs Collector tool.
  2. Implementing the necessary logic within the ECS Logs Collector to disable the debug logging for the Docker daemon and the Amazon ECS Container Agent when the "disable-debug" mode is used.
  3. Updating the ECS Logs Collector documentation to include instructions on how to use the new "disable-debug" mode.

Improve the Usage Documentation

It's really common when requesting logs customers send the output of the .sh execution but tho the collect.tgz/collect.tar.gz depending on the version.

Creating this ISSUE to update do the Pull request improving the README.md to have some information on how to collect the logs.

Add DateTime to the collect-i-*.tgz file name.

Summary

Add the Date Time YYYYMMDDHHmm to the file name, to if automated differ the time of the snapshot that the logs was collected from the same Container Instance

Description

  • Add the Date Time YYYYMMDDHHmm to the file name, to if automated differ the time of the snapshot that the logs was collected from the same Container Instance

[Feature Request] Collect GPU Info for GPU Container Instances

Summary

Added a routine to collect GPU details for GPU Container Instances

Description

Currently script doesn't collects GPU related information GPU Container Instances, this change will add output of:

  1. nvidia-smi -L listing GPUs
  2. nvidia-smi -q Details of all GPUs

Expected Behavior

Observed Behavior

"wget" didn't come on my Amazon Linux ECS box

After ssh'ing into my server, I found out that it didn't come with wget.

I had to install it using:

  • sudo yum install wget

I was wondering:

  • why my server didn't come with wget preinstalled
  • wether that yum line should be added to the readme

Detect required tools and optionally install if missing

Summary

Command line tools required by this script are checked at the time of the invocation, it would be more fitting to check their presence at the beginning and either notify the user what is missing and optionally offer to install them. Additional checks for certain functionalities (flag support, rudimentary version requirements) may be added based on usages but not necessary for consideration with this issue.

Creates wrong archive type

This may be a minor issue, but, this script produces a tgz, which can not be uploaded to GitHub. So the user has to uncompress and create a zip file.

script hangs on collecting Docker information

Hi,

I'm trying to execute this script on a post-mortem EC2 instance (stopped and started again). It hangs on the line:

Trying to gather Docker daemon information...

Here is the full output:

[ec2-user@ip-172-31-21-122 ~]$ sudo bash ecs-logs-collector.sh --mode=debug
Trying to check if the script is running as root... ok
Trying to check disk space usage... ok
Trying to collect system information... Amazon Linux AMI release 2016.09
ok
Trying to collect common operating system logs... ok
Trying to get mount points and volume information... ok
Trying to check SELinux status... ok
Trying to get iptables list... ok
Trying to detect installed packages... ok
Trying to detect active system services list... ok
Trying to gather Docker daemon information... 

Switching modes doesn't help.

Feature Request: dmesg logs Human Readable timestamps

Summary

The dmesg logs can be collected with Human readable timestamps with a simple flag. "-T"

Description

In the "get_kernel_logs()" function, change "dmesg" to "dmesg -T"

Expected Behavior

Observed Behavior

Consider collecting aws-appmesh.log

The recent App Mesh CNI integration with proxyConfiguration logs to /var/log/ecs/aws-appmesh.log.yyy-mm-dd-hh

Raising this to create awareness and determine if this is useful to collect in the ecs-logs-collector

Change variable infodir to use instanceId rather than the word collect

To make it easier to associate an extracted zip file with a specific instance, if we can make:
infodir="${curdir}/collect"
to something more like:
infodir="${curdir}/${instanceId}"
this would help a lot when viewing multiple instances logs. Perhaps even with the collection date in-case multiple logs from the one instance over multiple times of collection.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.