为了分析postgres日志,我们的工作流程是:
我们希望包含一些异常值,例如在应用程序启动时,因为对我们来说,它们是无用的数据,只会污染日志文件。
要做到这一点:如何/在哪里指定工作时间(from..to)筛选器?
理想的解决方案是在postgres中设置过滤器。
不太理想,过滤在rsyslog。
最后一种选择是在pgbadger上过滤: html输出将被裁剪,但是我们的服务器一直在编写胖日志文件。
当前rsyslog配置:
:msg, contains, "connection authorized: user=root database=root" ~
:msg, contains, "FATAL: database \"root\" does not exist" ~
local0.* -/var/log/postgresql.log发布于 2018-10-15 15:23:14
可以使用保存当前时间的系统属性(如rsyslog.conf和minute )使用在hour中的时间来指定筛选器。例如,
if $hour >= '10' and $hour <='17' then /var/log/output据我所知,小时和分钟值是带前导为零的两个字符串。
您可以将其与工具的测试(local0等)结合起来,例如:
if ( $syslogfacility-text=='local0' ) and ( $hour <= '10' or $hour>='20' ) then stop( stop是表示~的较新方式),或者如果您愿意的话
if ( $syslogfacility-text=='local0' ) and ( $hour > '10' and $hour<'20' ) then /var/log/output注意,这些过滤器必须位于从第一列开始的一行上。
https://serverfault.com/questions/935288
复制相似问题