Syslog-Ng

匹配 syslog-ng 中 nxlog 中設置的 SourceName

  • January 31, 2017

這讓我有點發瘋。如何根據程序名稱從 syslog-ng 收到的 nxlog 路由消息?它應該是不言自明的,但它不能正常工作。這些消息被放入我的 syslog-ng 通用日誌文件中,而沒有應用過濾。

我正在使用 nxlog 發送這樣的 IIS 日誌:

<Input W3SVC>
   Module im_file
   ...
   Exec $SourceName = 'IIS';
   ...
</Input>
<Route W3SVC>
   Path W3SVC => IIS_Syslog
</Route>
<Output IIS_Syslog>
  Module om_udp
  Host xxx
  Port xxx
  Exec to_syslog_ietf();
</Output>

它發送到 syslog-ng 伺服器,該伺服器應使用以下過濾器擷取。

filter f_iis {
   source ('IIS'); 
};

或者,我嘗試了以下方法。

filter f_iis {
   program ('IIS'); 
};

如果您將其作為普通 syslog 發送(即使用to_syslog_bsd()in nxlog.conf),那麼 $SourceName (= IIS) 的值將出現在 RFC3164 呼叫部分的消息中TAG

The value in the TAG field will be the name of the program or
process that generated the message.

Syslog-ng 呼叫這個program,所以我相信第二個應該做你需要的:

filter f_iis {
    program ('IIS'); 
};

引用自:https://serverfault.com/questions/829504