1
我嘗試在Grok過濾器中使用多行,但其工作不正常。Logstash - grok multiline
我的日誌是
H3|15:55:04:760|exception|not working properly
message:space exception
at line number 25
我的conf文件
input { file {
path => "logs/test.log"
start_position => beginning
sincedb_path => "/dev/null"
}}
filter{
multiline {
pattern => "^(\s|[A-Z][a-z]).*"
what => "previous"
}
if [message] =~ /H\d+/{
grok {
match => ["message", "(?m)%{USERNAME:level}\|%{TIME:timestamp}\|%{WORD:method}\|%{GREEDYDATA:error_Message}" ]
}
}
else {
grok {
match => ["message", "(?m)%{GREEDYDATA:error_Message}" ]
}
}
}
output {elasticsearch { host => "localhost" protocol => "http" port => "9200" }}
我能夠處理日誌文件的第一行,但日誌文件的第二行不工作,我想使用多
輸出我想有
{
"@timestamp" => "2014-06-19 00:00:00,000"
"path" => "logs/test.log"
"level"=>"H3"
"timestamp"=>15:55:04:760
"method"=>exception
"error_message"=>not working properly
},
{
"@timestamp" => "2014-06-19 00:00:00,000"
"path" => "logs/test.log"
"error_message" => "space exception at line 25"
}
請幫助我獲得所需的輸出。
你認爲你的正則表達式匹配了什麼? 「^(\ s | [A-Z] [a-z])*」 – 2015-04-02 16:16:21
嗨,Alain是logstash和這個多行的新手,我認爲它會檢查第一個字母是從空格開始 – raj 2015-04-06 09:29:25