Last active
November 7, 2023 16:03
-
-
Save rubikill/4d0aa9849fe5a13ef8fa0f32f99dca0f to your computer and use it in GitHub Desktop.
Build psql report RDS using pgbadger
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
# sh export_log.sh db_identifier | |
# If any of this commands fail, stop script. | |
set -e | |
db_identifier=$1 | |
date=$(date -v-7H +'%Y-%m-%d-%H') | |
log_file=~/Desktop/postgresql.log.$date | |
report_file=~/Desktop/out.$date.html | |
page_size=100000 | |
aws rds download-db-log-file-portion --db-instance-identifier $db_identifier --log-file-name error/postgresql.log.$date --page-size $page_size --output text > $log_file | |
~/Downloads/pgbadger-master/pgbadger -f rds $log_file -o $report_file -p '%t:%r:%u@%d:[%p]:' -f stderr -j 8 | |
echo $report_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.