Skip to content

Instantly share code, notes, and snippets.

@wmnnd
Created December 7, 2022 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wmnnd/c4555be4d01189042d5780f5e42ba6b9 to your computer and use it in GitHub Desktop.
Save wmnnd/c4555be4d01189042d5780f5e42ba6b9 to your computer and use it in GitHub Desktop.
Fetch fly-log-shipper logs from S3
#/bin/bash
# You need to have the aws CLI installed and configured.
# Set the S3_BUCKET variable before using.
S3_BUCKET="your-s3-log-bucket"
echo "Fetching logs from S3 ..."
aws s3 sync "s3://$S3_BUCKET" ./aws_logs
echo "Concatenating log files ..."
for dir in $(find ./aws_logs/*/* -type d)
do
date=$(basename $dir);
app=$(dirname $dir);
log_file="$app/$date.log"
if [ -f "$log_file" ];
then
rm "$log_file";
fi
for log in $(find $dir/*.log.gz)
do
gunzip -c $log >> "$log_file"
done
done
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment