Created
June 27, 2017 09:58
-
-
Save jmlrt/27e4648261ec096f1ed2c00801327780 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Download and compress cloudwatch log for the specified group, stream and date | |
DATE=$1 | |
CLOUDWATCH_LOG_GROUP=$2 | |
CLOUDWATCH_LOG_STREAM=$3 | |
LOG_FILE="${DATE}-${CLOUDWATCH_LOG_GROUP}-${CLOUDWATCH_LOG_STREAM}.log" | |
echo "Installing awslog tools" | |
pip install --user awslogs | |
echo "Cleaning workspace directory" | |
find . -name '*.gz' -delete | |
echo "Retrieving logs on Cloudwatch" | |
~/.local/bin/awslogs get --no-group --no-stream --start "${DATE} 00:00:00" --end "${DATE} 23:59:59" \ | |
${CLOUDWATCH_LOG_GROUP} ${CLOUDWATCH_LOG_STREAM} > ${LOG_FILE} | |
echo "Compressing log files" | |
gzip ${LOG_FILE}.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment