PostgreSQL Reporting Tools(Pgbadger) Installation & Configuration
PgBadger:
The PostgreSQL log analyzer “pgBadger” is an open source “fast PostgreSQL log analysis report” program written in Perl that takes the log output from a running PostgreSQL instance and processes it into an HTML file.
The report it generates shows all information found in a nice and easy to read report format.
These reports can help shed light on errors happening in the system, checkpoint behavior, vacuum behavior, trends, and other basic but crucial information for a PostgreSQL system.
FEATURES:
pgBadger reports everything about your SQL queries:
- Overall statistics.
- The most frequent waiting queries.
- Queries that waited the most.
- Queries generating the most temporary files.
- Queries generating the largest temporary files.
- The slowest queries.
- Queries that took up the most time.
- The most frequent queries.
- The most frequent errors.
- Histogram of query times.
- Histogram of sessions times.
- Users involved in top queries.
- Applications involved in top queries.
- Queries generating the most cancellation.
- Queries most cancelled.
The following reports are also available with hourly charts divided into periods of five minutes:
- SQL queries statistics.
- Temporary file statistics.
- Checkpoints statistics.
- Autovacuum and autoanalyze statistics.
- Cancelled queries.
- Error events (panic, fatal, error and warning).
- Error class distribution.
There are also some pie charts about distribution of:
- Locks statistics.
- Queries by type (select/insert/update/delete).
- Distribution of queries type per database/application
- Sessions per database/user/client/application.
- Connections per database/user/client/application.
- Autovacuum and autoanalyze per table.
- Queries per user and total duration per user.
pgBadger is also able to parse PgBouncer log files and to create the following reports:
- Request Throughput
- Bytes I/O Throughput
- Queries Average duration
- Simultaneous sessions
- Histogram of sessions times
- Sessions per database
- Sessions per user
- Sessions per host
- Established connections
- Connections per database
- Connections per user
- Connections per host
- Most used reserved pools
- Most Frequent Errors/Events
How to install pgbadger:
[root@server1 bin]# yum install pgbadger
Bin Path:
/usr/bin/pgbadger
Configuration:
vi postgresql.conf
log_destination = 'stderr' or 'csvlog' or 'syslog'
log_directory = 'log'
log_min_duration_statement = 0
log_checkpoints = on
log_connections = on
log_disconnections = on
log_lock_waits = on
log_temp_files = 0
log_autovacuum_min_duration = 0
log_error_verbosity = default
log_destination = ‘stderr’ or 'csvlog':
log_line_prefix = '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h '
log_destination = ‘syslog’:
log_line_prefix = 'user=%u,db=%d,app=%aclient=%h '
log_statement = 'all'
lc_messages='C'
PgBadger Options:
-b | --begin datetime : start date/time for the data to be parsed in log
-e | --end datetime : end date/time for the data to be parsed in log
-f | --format logtype : possible values: syslog, stderr, jsonlog, cvs
-d | --dbname database : only report on entries for the given database
-h | --help : show this message and exit.
-o | --outfile filename: define the filename for the output. Default depends
on the output format: out.html
Run pgbadger Tool:
[root@server1 ~]# pgbadger /var/lib/pgsql/10/data/log/* -o /zzz/report.html
[========================>] Parsed 5961992 bytes of 5961992 (100.00%), queries: 34125, events: 107
LOG: Ok, generating html report...
Comments
Post a Comment