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