我正在尝试使用rsyslog虚拟机进行过滤和转发。
当我使用
*.* @@192.168.1.100:514它会将所有日志转发到日志服务器。
我需要做的是过滤掉包含‘that’和'flow‘的日志,并防止来自localhost的日志被发送到日志服务器。
我尝试了许多方法来实现这种组合,但都失败了。一旦我使用过滤器,我就不会收到任何发送到目的地的日志。
rsyslog.conf的其余完整内容为
# rsyslog configuration file
# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html
#### MODULES ####
# The imjournal module bellow is now used as a message source instead of imuxsock.
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
$ModLoad imjournal # provides access to the systemd journal
#$ModLoad imklog # reads kernel messages (the same are read from journald)
#$ModLoad immark # provides --MARK-- message capability
# Provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514
# Provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 514
#### GLOBAL DIRECTIVES ####
# Where to place auxiliary files
$WorkDirectory /var/lib/rsyslog
# Use default timestamp format
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
# Include all config files in /etc/rsyslog.d/
$IncludeConfig /etc/rsyslog.d/*.conf
# Turn off message reception via local log socket;
# local messages are retrieved through imjournal now.
$OmitLocalLogging on
# File to store the position in the journal
$IMJournalStateFile imjournal.state
#### RULES ####
if $msg contains 'testing' then @@192.168.1.100:514
#*.* @@192.168.1.100:514我的配置不起作用。
发布于 2016-05-05 22:41:05
首先,注意$IncludeConfig /etc/rsyslog.d/*.conf这一行。基本上,它的意思是所有.conf文件都将包含在您粘贴的rsyslog.conf文件中。因此,我建议您添加另一个文件,例如/etc/rsyslog.d/30-testing.conf,并将您的规则放在那里,而不是将您的规则放在该文件的底部。这样做更有条理,如果将来您的syslog配置增加了,也会很有帮助。
除此之外,如果它在没有过滤器的情况下工作,因此端口/防火墙不是问题,那么它实际上应该可以工作--您的过滤器行看起来很好。您可能已经这样做了,但也许可以尝试:
:msg, contains, "testing" @@192.168.1.100:514另外,您是否在每次更改配置文件时都重新启动rsyslog服务?您可能需要这样做。您还可以发布您正在使用的rsyslog的版本吗?
https://stackoverflow.com/questions/37034439
复制相似问题