nxlog parse_csv 在 IIS 日誌檔案中因奇數字符而失敗

nxlog parse_csv 在 IIS 日誌檔案中因奇數字符而失敗

我正在解析 IIS 日誌。

此錯誤顯示在我的 nxlog 事件日誌中:

2013-12-24 18:40:20 ERROR if-else failed at line 50, character 351 in C:\Program Files (x86)\nxlog\conf\nxlog.conf. statement execution has been aborted; procedure 'parse_csv' failed at line 50, character 225 in C:\Program Files (x86)\nxlog\conf\nxlog.conf. statement execution has been aborted; Invalid CSV input: '2012-06-20 14:31:37 10.1.0.16 GET /App_Themes/Authenticated/Styles/index.jsp - 80 - 192.168.0.93 "|dir 302 0 0 62'

這是日誌檔案中行的更好視圖

2012-06-20 14:31:37 10.1.0.16 GET /App_Themes/Authenticated/Styles/index.jsp - 80 - 192.168.0.93 |dir 302 0 0 62

這是我的 nxlog.conf 檔案;我在第 51 行將其切斷,因為剩下的只是路由。

define ROOT C:\Program Files (x86)\nxlog

Moduledir %ROOT%\modules
CacheDir %ROOT%\data
Pidfile %ROOT%\data\nxlog.pid
SpoolDir %ROOT%\data
LogFile %ROOT%\data\nxlog.log

SuppressRepeatingLogs TRUE
LogLevel INFO


#<Extension fileop>
#    Module      xm_fileop
#    <Schedule>
#        Every   1 hour
#        Exec    file_cycle('%ROOT%\data\nxlog.log', 5);
#    </Schedule>
#</Extension>

<Extension syslog>
    Module      xm_syslog
</Extension>

<Extension json>
    Module      xm_json
</Extension> 

<Extension w3c>
    Module      xm_csv
    Fields  $date, $time, $s-ip, $cs-method, $cs-uri-stem, $cs-uri-query, $s-port, $cs-username, $c-ip, $cs-User-Agent, $sc-status, $sc-substatus, $sc-win32-status, $time-taken
    FieldTypes  string, string, string, string, string, string, string, string, string, string, string, string, string, string
    Delimiter   ' '
    QuoteChar   '"'
    EscapeControl FALSE
    UndefValue  -
</Extension>


<Input iis_in>
    Module  im_file
    File    "f:\\iislogs\\u_*.log"
    ReadFromLast FALSE
    Exec    if $raw_event =~ /^#/ drop();                        \
                else                                             \
                {                                                \
                    w3c->parse_csv();                            \
                    $EventTime = parsedate($date + " " + $time); \
                    to_json(); \
                }
</Input>
  1. 這是我該擔心的事嗎?
  2. 這次被炸是因為「」這個字嗎?
  3. 我怎樣才能避免這種情況?

編輯:進一步的研究表明,這可能是由於“cs(用戶代理)”字段中的字元編碼錯誤造成的。不知道該怎麼辦。

#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken
2012-02-04 22:09:37 10.1.0.16 GET /login.aspx - 80 - 192.168.0.93 +xa7 403 4 5 218
2012-02-04 22:09:37 10.1.0.16 GET /signup/ - 80 - 192.168.0.93 +xa7 302 0 0 15
2012-02-04 22:09:37 10.1.0.16 GET /signup/ - 80 - 192.168.0.93 " 302 0 0 15
2012-02-04 22:09:37 10.1.0.16 GET /signup/ - 80 - 192.168.0.93 ߧߢ 302 0 0 0
2012-02-04 22:09:37 10.1.0.16 GET /signup/ - 80 - 192.168.0.93 

答案1

有點不清楚是否有您輸入的字元是否存在。嘗試將 QuoteChar 設定為雙引號以外的其他值。

相關內容