我正在尝试用;RSYSLOG_SyslogProtocol23Format转发rsyslog,它对所有日志转发都很好:*.* @@syslogserver.com:6789;RSYSLOG_SyslogProtocol23Format
但是,有谁知道如何在特定的规则上实现它呢?
if ($msg contains_i and so on)
action(type="omfwd" target="syslogserver.com" port="6789" protocol="tcp"
action.resumeRetryCount="-1"干杯!
发布于 2022-08-31 13:05:05
我不知道你所说的规则是什么意思,我想你指的是条件词或过滤器。
可以这样做一个简单的if语句:
if $msg contains 'test' then
action(type="omfwd" template="RSYSLOG_SyslogProtocol23Format" ...)..。也可以用链子:
if $programname == 'my_program' and $msg contains 'test' then
action(type="omfwd" template="RSYSLOG_SyslogProtocol23Format" ...)..。或者用一组语句来完成:
if $programname == 'my_program' then {
action(type="omfwd" ...)
if $msg contains 'test' then
action(type="omfwd" template="RSYSLOG_SyslogProtocol23Format" ...)
else
action(type="omfwd" ...)
}https://serverfault.com/questions/1109557
复制相似问题