将Logstash json消息分解为字段 [英] Decompose Logstash json message into fields

查看:909
本文介绍了将Logstash json消息分解为字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它有一个日志文件,用于存储带有时间戳和json消息的事件.例如:

It have a logfile that stores event with a timestamp and a json message. For example:

timestamp {"foo":12,"bar":13}

timestamp {"foo": 12, "bar": 13}

我想将json部分中的键(foo和bar)分解为Logstash输出中的字段.

I would like to decompose the keys (foo and bar) in the json part into fields in the Logstash output.

我知道我可以将Logstash文件过滤器中的format字段设置为json_event,但是在这种情况下,我必须在json中包含时间戳记.还有一个json过滤器,但是它添加了具有完整json数据结构的单个字段,而不是使用键.

I'm aware that I can set the format field in the Logstash file filter to json_event but in that case I have to include the timestamp in json. There is also a json filter, but that adds a single field with the complete json data structure, instead of using the keys.

有什么想法可以做到吗?

Any ideas how this can be done?

推荐答案

尝试使用最新的logstash 1.2.1,并使用编解码器值直接解析json事件.

Try the latest logstash 1.2.1 and use codec value to parse json events directly.

input {
    file {
        type => "tweetfile"
        path => ["/home/nikhil/temp/feed/*.txt"]
        codec => "json"
    }
}
filter{
    json{
        source => "message"
        target => "tweet"
    }
}
output {
    stdout { }
    elasticsearch { embedded => true }
}

这篇关于将Logstash json消息分解为字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆