pgBadger is Free Software and is made fully available free of charge.
pgBadger is a PostgreSQL log analyzer built for speed with fully detailed reports and professional rendering.
1. Review pgbadger to learn about it from official site
https://pgbadger.darold.net/
2. Install pgBadger as root or sudo user
dnf install -y pgbadger
output: Updating Subscription Management repositories. enterprisedb-enterprise 778 B/s | 659 B 00:00 enterprisedb-enterprise-noarch 823 B/s | 659 B 00:00 enterprisedb-enterprise-source 771 B/s | 659 B 00:00 Dependencies resolved. =================================================================================================================================================================================================================== Package Architecture Version Repository Size =================================================================================================================================================================================================================== Installing: pgbadger noarch 12.4-1PGDG.rhel8 pgdg-common 365 k Installing dependencies: perl-Text-CSV_XS x86_64 1.40-1.el8 epel 145 k perl-UNIVERSAL-isa noarch 1.20171012-4.el8 epel 24 k Transaction Summary =================================================================================================================================================================================================================== Install 3 Packages Total download size: 535 k Installed size: 1.9 M Downloading Packages: (1/3): perl-Text-CSV_XS-1.40-1.el8.x86_64.rpm 549 kB/s | 145 kB 00:00 (2/3): perl-UNIVERSAL-isa-1.20171012-4.el8.noarch.rpm 84 kB/s | 24 kB 00:00 (3/3): pgbadger-12.4-1PGDG.rhel8.noarch.rpm 284 kB/s | 365 kB 00:01 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 279 kB/s | 535 kB 00:01 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : perl-UNIVERSAL-isa-1.20171012-4.el8.noarch 1/3 Installing : perl-Text-CSV_XS-1.40-1.el8.x86_64 2/3 Installing : pgbadger-12.4-1PGDG.rhel8.noarch 3/3 Running scriptlet: pgbadger-12.4-1PGDG.rhel8.noarch 3/3 Verifying : perl-Text-CSV_XS-1.40-1.el8.x86_64 1/3 Verifying : perl-UNIVERSAL-isa-1.20171012-4.el8.noarch 2/3 Verifying : pgbadger-12.4-1PGDG.rhel8.noarch 3/3 Installed products updated. Installed: perl-Text-CSV_XS-1.40-1.el8.x86_64 perl-UNIVERSAL-isa-1.20171012-4.el8.noarch pgbadger-12.4-1PGDG.rhel8.noarch Complete!
3. Check pgBadger exists as user posgres
which pgbadger
ls -lrt /usr/bin/pgbadger
4. Run a test report as user postgres
postgres logs exist in : /var/lib/pgsql/16/data/log
ls -1
postgresql-Fri.log
postgresql-Mon.log
postgresql-Sat.log
postgresql-Sun.log
postgresql-Thu.log
postgresql-Tue.log
postgresql-Wed.log
We’ll pick one these providing full path to pgbager and output directory and filename:
-o | –outfile filename
-O | –outdir path
pgbadger /var/lib/pgsql/16/data/log/postgresql-Mon.log -O /var/tmp -o pgbadger_test.html
output: [========================>] Parsed 2352 bytes of 2352 (100.00%), queries: 0, events: 4 LOG: Ok, generating html report... #check report exists ls -lrt /var/tmp/pgbadger_test.html -rw-r--r--. 1 postgres postgres 792952 Jan 16 11:18 /var/tmp/pgbadger_test.html
5. View report in web browser: open /var/tmp/pgbadger_test.html