To analyze postgres logs, our workflow is:
- postgres logs via syslog
- rsyslog writes to one text file
- at midnight we stop postgres
- pgbadger reads and parses the daily logfile (about 2 Gbyte)
We want to esclude some outliers, for examples when the application starts, because for us they are useless data and just pollute the logfile.
To accomplish this: how/where can I specify a working hours (from..to) filter ?
The ideal solution is to set the filter in postgres.
Less than ideal, filter at rsyslog.
Last choice is to filter at pgbadger: the html output will be trimmed, but our servers keep writing fat logfiles.
current rsyslog configuration:
:msg, contains, "connection authorized: user=root database=root" ~
:msg, contains, "FATAL: database \"root\" does not exist" ~
local0.* -/var/log/postgresql.log
You can specify a filter using the time in
rsyslog.conf
using the system properties holding the current time, likehour
andminute
. For example,As I understand it, the hour and minute values are 2 character strings with leading zero.
You can combine this with a test for the facility (local0 and so on), for example:
(where
stop
is the newer way of saying~
), or if you preferNote that these filters must be on one line starting in the first column.