步驟1.collectd尾插件ExcludeRegex不工作
LoadPlugin tail
<Plugin "tail">
<File "/etc/nginx/access.log">
<Match>
Regex "HTTP/1..\" 4"
ExcludeRegex "HTTP/1..\" 404"
ExcludeRegex "HTTP/1..\" 499"
DSType "CounterInc"
Type "counter"
Instance "4xx-excluded-404-and-499"
</Match>
</File>
</Plugin>
我使用collectd版本5.5.0。然後,我們嘗試使用collectd的尾部插件來收集Nginx訪問日誌的狀態代碼的指標。 但是,如果您嘗試使用ExcludeRegex「HTTP/1 ..」404和ExcludeRegex「HTTP/1 ..」499「,ExcludeRegex」HTTP/1 .. \「499」'將起作用,ExcludeRegex 404將無法工作。
我發現通過分別創建單獨的匹配並使用相應的ExcludeRegex可以很好地工作。以下運作良好。
LoadPlugin tail
<Plugin "tail">
<File "/etc/nginx/access.log">
<Match>
Regex "HTTP/1..\" 4"
ExcludeRegex "HTTP/1..\" 404"
DSType "CounterInc"
Type "counter"
Instance "4xx-excluded-404"
</Match>
<Match>
Regex "HTTP/1..\" 4"
ExcludeRegex "HTTP/1..\" 499"
DSType "CounterInc"
Type "counter"
Instance "4xx-excluded-499"
</Match>
</File>
</Plugin>
但是,如果他們在同一場比賽中,兩人不工作。
此外,access.log的內容是以下模式。
127.0.0.1 - - [01/Dec/2016:18:44:15 +0900] "GET /v3/intro HTTP/1.1" 200
127.0.0.1 - - [01/Dec/2016:18:44:15 +0900] "GET /v3/intro HTTP/1.1" 404
127.0.0.1 - - [01/Dec/2016:18:44:15 +0900] "GET /v3/intro HTTP/1.1" 499
步驟2.
<Plugin "tail">
<File "/etc/nginx/access.log">
<Match>
Regex "HTTP/1..\" 4"
ExcludeRegex "healthcheck"
ExcludeRegex "HTTP/1..\" 499"
DSType "CounterInc"
Type "counter"
Instance "4xx-excluded-404-and-499"
</Match>
</File>
</Plugin>
其次,我試圖測試collectd具有上述結構。這一次,我確認Multi line ExcludeRegex應用得很好。所以,我認爲如果相同的正則表達式在其中,我懷疑可能會出現問題。
它爲什麼不起作用?幫我。
謝謝。