【发布时间】:2014-03-04 13:10:04
【问题描述】:
背景:
我有一个自定义生成的日志文件,它具有以下模式:
[2014-03-02 17:34:20] - 127.0.0.1|ERROR| E:\xampp\htdocs\test.php|123|subject|The error message goes here ; array (
'create' =>
array (
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3'
),
)
[2014-03-02 17:34:20] - 127.0.0.1|DEBUG| flush_multi_line
第二个条目[2014-03-02 17:34:20] - 127.0.0.1|DEBUG| flush_multi_line 是一个虚拟行,只是为了让logstash 知道多行事件已经结束,此行稍后会被删除。
我的配置文件如下:
input {
stdin{}
}
filter{
multiline{
pattern => "^\["
what => "previous"
negate=> true
}
grok{
match => ['message',"\[.+\] - %{IP:ip}\|%{LOGLEVEL:loglevel}"]
}
if [loglevel] == "DEBUG"{ # the event flush line
drop{}
}else if [loglevel] == "ERROR" { # the first line of multievent
grok{
match => ['message',".+\|.+\| %{PATH:file}\|%{NUMBER:line}\|%{WORD:tag}\|%{GREEDYDATA:content}"]
}
}else{ # its a new line (from the multi line event)
mutate{
replace => ["content", "%{content} %{message}"] # Supposing each new line will override the message field
}
}
}
output {
stdout{ debug=>true }
}
content 字段的输出是:The error message goes here ; array (
问题:
我的问题是我想将多行的其余部分存储到内容字段:
The error message goes here ; array (
'create' =>
array (
'key1' => 'value1',
'key2' => 'value2',
'key3' => 'value3'
),
)
所以我可以稍后删除消息字段。
@message 字段包含整个多行事件,因此我尝试了 mutate 过滤器,并使用了 replace 功能,但我'我只是无法让它工作:(。
我不了解 Multiline 过滤器的工作方式,如果有人能对此有所了解,将不胜感激。
谢谢,
阿卜杜。
【问题讨论】:
标签: regex logstash multiline logstash-grok