82
85
--disable-temporary : do not generate temporary report.
83
86
--disable-checkpoint : do not generate checkpoint report.
84
87
--disable-autovacuum : do not generate autovacuum report.
88
--charset : used to set the HTML charset to be used. Default: utf-8.
89
--csv-separator : used to set the CSV field separator, default: ,
90
--exclude-time regex : any timestamp matching the given regex will be
91
excluded from the report. Example: "2013-04-12 .*"
92
You can use this option multiple times.
93
--exclude-appname name : exclude entries for the specified application name
94
from report. Example: "pg_dump".
119
129
This supposes that your log file and HTML report are also rotated every
132
Or better, use the auto-generated incremental reports:
134
0 4 * * * /usr/bin/pgbadger -I -q /var/log/postgresql/postgresql.log.1 \
135
-O /var/www/pg_reports/
137
will generate a report per day and per week in the given output
140
If you have a pg_dump at 23:00 and 13:00 each day during half an hour,
141
you can use pgbadger as follow to exclude these periods from the report:
143
pgbadger --exclude-time "2013-09-.* (23|13):.*" postgresql.log
145
This will help to not have all COPY order on top of slowest queries. You
146
can also use --exclude-appname "pg_dump" to solve this problem in a more
123
pgBadger is a PostgreSQL log analyzer built for speed with fully
150
pgBadger is a PostgreSQL log analyzer build for speed with fully
124
151
detailed reports from your PostgreSQL log file. It's a single and small
125
Perl script that aims to replace and out-perform the old PHP script
128
By the way, we would like to thank Guillaume Smet for all the work he
129
has done on this really nice tool. We've been using it a long time, it
130
is a really great tool!
132
pgBadger is written in pure Perl language. It uses a Javascript library
133
to draw graphs so that you don't need additional Perl modules or any
134
other package to install. Furthermore, this library gives us additional
135
features, such as zooming.
152
Perl script that outperform any other PostgreSQL log analyzer.
154
It is written in pure Perl language and uses a javascript library
155
(flotr2) to draw graphs so that you don't need to install any additional
156
Perl modules or other packages. Furthermore, this library gives us more
157
features such as zooming. pgBadger also uses the Bootstrap javascript
158
library and the FontAwesome webfont for better design. Everything is
137
161
pgBadger is able to autodetect your log file format (syslog, stderr or
138
csvlog). It is designed to parse huge log files, as well as gzip, zip or
139
bzip2 compressed files. See a complete list of features below.
162
csvlog). It is designed to parse huge log files as well as gzip
163
compressed file. See a complete list of features below.
165
All charts are zoomable and can be saved as PNG images.
167
You can also limit pgBadger to only report errors or remove any part of
168
the report using command line options.
170
pgBadger supports any custom format set into log_line_prefix of your
171
postgresql.conf file provide that you use the %t, %p and %l patterns.
173
pgBadger allow parallel processing on a single log file and multiple
174
files through the use of the -j option and the number of CPUs as value.
176
If you want to save system performance you can also use log_duration
177
instead of log_min_duration_statement to have reports on duration and
178
number of queries only.
142
181
pgBadger reports everything about your SQL queries:
145
184
The most frequent waiting queries.
146
185
Queries that waited the most.
147
186
Queries generating the most temporary files.
150
189
Queries that took up the most time.
151
190
The most frequent queries.
152
191
The most frequent errors.
154
The following reports are also available with hourly charts:
156
Hourly queries statistics.
157
Hourly temporary file statistics.
158
Hourly checkpoints statistics.
159
Hourly restartpoints statistics.
192
Histogram of query times.
194
The following reports are also available with hourly charts divide by
195
periods of five minutes:
197
SQL queries statistics.
198
Temporary file statistics.
199
Checkpoints statistics.
200
Autovacuum and autoanalyze statistics.
202
There's also some pie reports of distribution about:
160
204
Locks statistics.
161
Queries by type (select/insert/update/delete).
205
ueries by type (select/insert/update/delete).
162
206
Distribution of queries type per database/application
163
207
Sessions per database/user/client.
164
208
Connections per database/user/client.
200
247
Note that multiprocessing can not be used with compressed files or CSV
201
248
files as well as under Windows platform.
251
Download the tarball from github and unpack the archive as follow:
253
tar xzf pgbadger-4.x.tar.gz
256
make && sudo make install
258
This will copy the Perl script pgbadger to /usr/local/bin/pgbadger by
259
default and the man page into /usr/local/share/man/man1/pgbadger.1.
260
Those are the default installation directories for 'site' install.
262
If you want to install all under /usr/ location, use INSTALLDIRS='perl'
263
as an argument of Makefile.PL. The script will be installed into
264
/usr/bin/pgbadger and the manpage into /usr/share/man/man1/pgbadger.1.
266
For example, to install everything just like Debian does, proceed as
269
perl Makefile.PL INSTALLDIRS=vendor
271
By default INSTALLDIRS is set to site.
203
273
POSTGRESQL CONFIGURATION
204
274
You must enable and set some configuration directives in your
205
275
postgresql.conf before starting.
322
394
are all named with the following template tmp_pgbadgerXXXX.bin so they
323
395
can be easily identified.
326
Download the tarball from github and unpack the archive as follow:
328
tar xzf pgbadger-3.x.tar.gz
331
make && sudo make install
333
This will copy the Perl script pgbadger to /usr/local/bin/pgbadger by
334
default and the man page into /usr/local/share/man/man1/pgbadger.1.
335
Those are the default installation directories for 'site' install.
337
If you want to install all under /usr/ location, use INSTALLDIRS='perl'
338
as an argument of Makefile.PL. The script will be installed into
339
/usr/bin/pgbadger and the manpage into /usr/share/man/man1/pgbadger.1.
341
For example, to install everything just like Debian does, proceed as
344
perl Makefile.PL INSTALLDIRS=vendor
346
By default INSTALLDIRS is set to site.
398
pgBadger include an automatic incremental report mode using option -I or
399
--incremental. When running in this mode, pgBadger will generate one
400
report per day and a cumulative report per week. Output is first done in
401
binary format into the mandatory output directory (see option -O or
402
--outdir), then in HTML format for daily and weekly reports with a main
405
The main index file will show a dropdown menu per week with a link to
406
the week report and links to daily reports of this week.
408
For example, if you run pgBadger as follow based on a daily rotated
411
0 4 * * * /usr/bin/pgbadger -I -q /var/log/postgresql/postgresql.log.1 \
412
-O /var/www/pg_reports/
414
you will have all daily and weekly reports for the full running period.
416
In this mode pgBagder will create an automatic incremental file into the
417
output directory, so you don't have to use the -l option unless you want
418
to change the path of that file. This mean that you can run pgBadger in
419
this mode each days on a log file rotated each week, it will not count
420
the log entries twice.
423
Using the binary format it is possible to create custom incremental and
424
cumulative reports. For example, if you want to refresh a pgbadger
425
report each hour from a daily PostgreSQl log file, you can proceed by
426
running each hour the following commands:
428
pgbadder --last-parsed .pgbadger_last_state_file -o sunday/hourX.bin /var/log/pgsql/postgresql-Sun.log
430
to generate the incremental data files in binary format. And to generate
431
the fresh HTML report from that binary file:
433
pgbadder sunday/*.bin
435
Or an other example, if you have one log file per hour and you want a
436
reports to be rebuild each time the log file is switched. Proceed as
439
pgbadger -o day1/hour01.bin /var/log/pgsql/pglog/postgresql-2012-03-23_10.log
440
pgbadger -o day1/hour02.bin /var/log/pgsql/pglog/postgresql-2012-03-23_11.log
441
pgbadger -o day1/hour03.bin /var/log/pgsql/pglog/postgresql-2012-03-23_12.log
444
When you want to refresh the HTML report, for example each time after a
445
new binary file is generated, just do the following:
447
pgbadger -o day1_report.html day1/*.bin
449
Adjust the commands following your needs.
349
pgBadger is an original work from Gilles Darold. It is maintained by the
350
good folk at Dalibo and everyone who wants to contribute.
452
pgBadger is an original work from Gilles Darold.
454
The pgBadger logo is an original creation of Damien Clochard.
456
The pgBadger v4.x design comes from the "Art is code" company.
458
This web site is a work of Gilles Darold.
460
pgBadger is maintained by Gilles Darold, the good folks at Dalibo, and
461
every one who wants to contribute.
463
Many people have contributed to pgBadger, they are all quoted in the
353
467
pgBadger is free software distributed under the PostgreSQL Licence.
355
Copyright (c) 2012-2013, Dalibo
469
Copyright (c) 2012-2014, Dalibo
357
471
A modified version of the SQL::Beautify Perl Module is embedded in
358
472
pgBadger with copyright (C) 2009 by Jonas Kramer and is published under