简体   繁体   English

如何使用Logstash过滤作为哈希值的消息

[英]How to use logstash to grok the message which is a hash

All 所有

I'm using logstash to ship logs from the remote server. 我正在使用logstash从远程服务器发送日志。 The message i got is a hash type like this: 我收到的消息是这样的哈希类型:

[2014-12-06 23:59:57] 112.254.70.37 <AUDIO> {"type":"Stat", "eid":4800316, "mid":"87192133091532", "ccid":3228662, "ver":102, "ip":"114.113.200.227", "port":9081, "jitter":"0 0 0 0 0 ", "break":"0 0 0 0 0 ", "interrupt":"0 0 0 0 0 ", "tcp_rtt":"40 40 45 50 50 ", "udp_rtt":"31 33 35 40 35 ", "all_pkts":"107180 107193 107249 107323 107358 ", "lost":"0 0 0 0 0 ", "delay":"40.78", "pull":"3 3 3 3 3 "}

Then how can I write the grok part, I search the doc everywhere, but i still don't konw how... thx! 那我该怎么写grok的部分,我到处搜索文档,但是我还是不知道怎么... thx!

First, you have to parse out your json data by grok filter. 首先,您必须通过grok过滤器解析出json数据。 Then, use json filter to parse all the hashmap value. 然后,使用json过滤器解析所有hashmap值。 With this config I can parse your log and create all the field : value . 使用此配置,我可以解析您的日志并创建所有fieldvalue Hope this can help you. 希望这可以帮到你。

input {
    stdin{
    }
}

filter {
    grok {
    match => [ "message" , "\[%{TIMESTAMP_ISO8601:datatime}\] %{IP:ip} <%{WORD:level}> %{GREEDYDATA:data}"]
    }
    json {
            source => "data"
    }
}

output {
    stdout{
            codec => rubydebug
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM