你不会是程序猿吧?

logstash 怎么解析多层JSON数据

Logstash | 作者 playlong00 | 发布于2018年09月03日 | 阅读数:5223

想解析多层的json数据格式,但两次json解析不行,好像是数据格式已经不对了原始数据:{"timestamp": "2018-09-03T11:43:15+08:00","other": {"content-type": "abc"}}
 
我的logstash配置

input {
      stdin{}
}
filter { 
  json {
    source => "message" }
  json {
    source => "other"}
}
output{
stdout{}


改怎么配置 才能获取这种:

{
"timestamp": "2018-09-03T11:43:15+08:00",
"content-type": "abc"
}

666QQ截图20180903172531.jpg
已邀请:

rochy - rochy_he

赞同来自:

filter { 
json {
source => "other",
add_field => { "timestamp" => "%{timestamp}" }
}
}

可以试一下上面的配置

zyy

赞同来自:

一次json已经全转换了,你可以用mutate对other.content-type这个字段重命名,或者对other字段json_encode后再json

要回复问题请先登录注册