Created
December 7, 2022 14:28
-
-
Save wmnnd/c4555be4d01189042d5780f5e42ba6b9 to your computer and use it in GitHub Desktop.
Fetch fly-log-shipper logs from S3
This file contains 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 | |
# 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