SyslogNG - フィルタリングとロギングステートメントを最適化する方法は? [閉鎖]

SyslogNG - フィルタリングとロギングステートメントを最適化する方法は? [閉鎖]

以下は、ローカルSyslog-NGロギングの現在の設定です。

source s_network {
        udp(
                flags(syslog_protocol)
                keep_hostname(yes)
                keep_timestamp(yes)
                use_dns(no)
                use_fqdn(no)
        );
};

destination d_all_logs {
        file("/app/syslog-ng/custom/output/all_devices.log");

};

log {
        source(s_network);
        destination(d_all_logs);
};

特定のメッセージを転送するには...追加する設定は次のとおりです。

filter message_filter_string_1{ 
            match("01CONFIGURATION\/6\/hwCfgChgNotify\(t\)", value("MESSAGE"));
            }


filter message_filter_string_2{
            match("01SHELL\/5\/CMDRECORD", value("MESSAGE"));
            }

filter message_filter_string_3{
            match("10SHELL", value("MESSAGE"));
            }

filter message_filter_string_4{
            match("ACE-1-111008:", value("MESSAGE"));
            }

destination remote_log_server {
 udp("192.168.0.20" port(25214));
};

log { source(s_network); filter(message_filter_string_1); destination(remote_log_server); };

log { source(s_network); filter(message_filter_string_2); destination(remote_log_server); };

log { source(s_network); filter(message_filter_string_3); destination(remote_log_server); };

log { source(s_network); filter(message_filter_string_4); destination(remote_log_server); };

実際、そのようなフィルタは80を超えています。

Syslog-NG設定では、OR一致を含む単一の文を使用して構文を作成できますかfilterregex1regex2regex3

(または)

logSyslog-NG構成では、複数のフィルタを含む単一のステートメントを使用して構文を作成できますか?

ベストアンサー1

複数の一致文を結合するには、以下を使用しますor

filter send_remote { 
            match("01CONFIGURATION\/6\/hwCfgChgNotify\(t\)", value("MESSAGE")) 
  or
            match("01SHELL\/5\/CMDRECORD", value("MESSAGE")) 
  or
            match("10SHELL", value("MESSAGE"))
  or
            match("ACE-1-111008:", value("MESSAGE"));

            }

...その後、そのフィルタ名を一度使用します。

log { source(s_network); filter(send_remote); destination(remote_log_server); };

おすすめ記事