问题描述
我需要将消息从日志文件转发到另一个 IP - 比如说 127.0.0.1 514
。我如何实现这一目标?
我使用了 rsyslog 文档中的 this example:
module(load="imfile" PollingInterval="10") #needs to be done just once
# File 2
input(type="imfile"
File="/path/to/file2"
Tag="tag2")
以及为其提供以下规则:
*.* @127.0.0.1:514
但这最终发送了包括 journald 在内的所有系统日志。
那么如何正确使用规则集、输入块和 *.* @127.0.0.1:514
将日志从文件 /path/to/file2
发送到 127.0.0.1:514
?
谢谢
解决方法
指定输入时,还要说明要应用的规则集。规则集之外的输入不会被规则集处理。
module(load="imfile")
input(type="imfile" File="/path/to/file2" Tag="tag2" ruleset="remote")
ruleset(name="remote"){
action(type="omfwd" target="127.0.0.1" port="514" protocol="udp")
# or use legacy syntax:
# *.* @127.0.0.1:514
}