本文主要是介绍logstash解析嵌套json格式数据,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
现有json:
{"name":"zhangsan","friends":{"friend1":"lisi","friend2":"wangwu","msg":["haha","yaya"]}
}
将其解析为:
{"name":"zhangsan","friend1":"lisi","friend2":"wangwu","msg":["haha","yaya"]
}
logstash.conf
input
{stdin{codec => json}
}filter
{mutate{add_field => { "@friends" => "%{friends}" } #先新建一个新的字段,并将friends赋值给它}json{source => "@friends" #再进行解析remove_field => [ "@alert","alert" ] #删除不必要的字段,也可以不用这语句}
}output
{stdout { }
}
这篇关于logstash解析嵌套json格式数据的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!