Syslog 剖析器支援 message_decoder 和 extract_sd 選項,並且會自動偵測三種格式:RFC-6587、RFC-5424 和 RFC-3164。
設定 message_decoder 選項
Syslog 剖析器可使用所有一般選項和 message_decoder 選項。預設只會擷取 timestamp 和 appname 欄位。透過將 liagent.ini 檔案中的組態值設定為類似下列範例,啟用 message_decoder 選項:
[filelog|data_logs] directory=D:\Logs include=*.txt parser=mysyslog [parser|mysyslog] base_parser=syslog message_decoder=syslog_message_decoder debug=yes [parser|syslog_message_decoder] base_parser=kvp fields=*
透過 message_decoder 選項進行剖析
下列範例顯示範例事件,以及由設定為使用 message_decoder 選項之 Syslog 剖析器新增至事件的欄位:
- 範例事件:
2015-09-09 13:38:31.619407 +0400 smith01 john: Fri Dec 5 08:58:26 2014 [pid 26123] [jsmith.net] status_code=FAIL oper_ ation=LOGIN: Client "176.31.17.46"
- 套用 message_decoder 選項以執行 KVP 剖析器之 Syslog 剖析器傳回的項目:
timestamp=2015-09-09T09:38:31.619407 appname=john status_code=FAIL operation=LOGIN:
設定 extract_sd 選項以剖析結構化資料
若要剖析結構化資料,請透過將 liagent.ini 檔案中的組態值設定為類似下列範例,啟用 extract_sd 選項:
[filelog|simple_logs] directory=/var/log include=*.txt parser=syslog_parser [parser|syslog_parser] base_parser=syslog extract_sd=yes
透過 extract_sd 選項進行剖析
下列範例顯示範例事件,以及由設定為使用 extract_sd 選項之 Syslog 剖析器新增至事件的欄位:
- 範例事件:
<165>1 2017-01-24T09:17:15.719Z localhost evntslog - ID47 [exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"][examplePriority@32473 class="high"] Found entity IPSet, display name dummy ip set 1411 - Syslog 剖析器會將下列欄位新增至事件:
timestamp=2017-01-24T09:17:15.719000 pri_facility=20 pri_severity=5 procid="-" msgid="ID47" iut="3" eventsource="Application" eventid="1011" class="high" appname="evntslog"
剖析器擷取的欄位
剖析器會從事件中自動擷取下列欄位:
| RFC 分類 | pri_facility | pri_severity | timestamp | appname | procid | msgid |
|---|---|---|---|---|---|---|
| 非 RFC | X | X | ||||
| RFC-3164 | X | X | X | X | ||
| RFC-5424 | X | X | X | X | X | X |
Syslog 剖析器選項
下表說明可用的 Syslog 選項。
| 選項 | 說明 |
|---|---|
message_decoder |
定義用於剖析事件訊息內文的其他剖析器。其可為內建剖析器 (例如「auto」) 或任何自訂定義的剖析器。 |
extract_sd |
剖析結構化資料。 extract_sd 選項只支援 yes 或 no 值。依預設,會停用該選項。啟用 extract_sd 選項時,其只會從結構化資料中擷取所有索引鍵-值配對。 |
RFC-5424 標準剖析
下列範例顯示設定之 Syslog 執行個體所剖析的兩個事件,並顯示收集器使用的組態、範例事件和 Syslog 剖析器新增至事件的欄位。- 組態:
[filelog|simple_logs] directory=/var/log include=*.txt parser=syslog
- 監控之檔案所產生的事件:
<165>1 2017-01-24T09:17:15.719Z router1 mgd 3046 UI_DBASE_LOGOUT_EVENT [[email protected] username=\"regress\"] User 'regress' exiting configuration mode - Juniper format - Syslog 剖析器新增至事件的欄位:
The following fields will be added to the event by Syslog parser: timestamp=2017-01-24T09:17:15.719000 pri_facility = 20 pri_severity = 5 procid = 3046 msgid = UI_DBASE_LOGOUT_EVENT appname = mgd
RFC-3164 標準剖析
下列範例顯示收集器使用的組態、RFC-3164 範例事件和 Syslog 新增至事件的欄位。
- 組態:
[filelog|simple_logs] directory=/var/log include=*.txt parser=syslog
- 監控之檔案所產生的 RFC-3164 事件:
<13>2017-01-24T09:17:15.719Z router1 mgd 3046 UI_DBASE_LOGOUT_EVENT User 'regress' exiting configuration mode - Juniper format
- Syslog 剖析器新增至事件的欄位:
timestamp=2017-01-24T09:17:15.719000 pri_facility=1 pri_severity=5 appname="mgd"