logstash之filter处理中括号包围的内容
Posted zhzhang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了logstash之filter处理中括号包围的内容相关的知识,希望对你有一定的参考价值。
如题,logstash之filter处理中括号包围的内容:
$grep -v "#" config/logstash-nlp.yml
input {
kafka {
bootstrap_servers => "datacollect-1:9092,datacollect-2:9092,datacollect-3:9092"
codec => "json"
group_id => "logstash-newtrace-nlptemp"
topics => ["ot-nlp"]
}
}
filter {
grok {
match => {
"message" => "^[%{GREEDYDATA:request}]$"
}
}
json {
source => "request"
}
ruby {
code => "event.set(‘temptime‘, event.get(‘@timestamp‘).time.localtime + 8*60*60);"
}
grok {
match => ["temptime", "%{DATA:thedate}T%{NOTSPACE:thetime}Z"]
}
}
output {
if ([kafka][topic] =~ "^ot-nlp*") {
if [name] == "nlp" {
file {
codec => line {format => "%{request}"}
path => "/tmp/newtrace_nlp.log.%{thedate}"
}
}
}
}
摘出来数组中的所有fields
filter { grok { match => { "message" => "^[%{GREEDYDATA:request}]$" } } json { source => "request" remove_field => [ "message", "request" ] } split { field => "binaryAnnotations" } json { source => "[binaryAnnotations][value]" } }
感谢时总的大力支持!!!
核心就是正则!
match => {
"message"
=>
"^[%{GREEDYDATA:request}]$"
}
以上是关于logstash之filter处理中括号包围的内容的主要内容,如果未能解决你的问题,请参考以下文章
Logstash之Logstash inputs(file和redis插件)Logstash outputs和Filter plugins