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 { }
}

你可能感兴趣的:(大数据)