在流利的情况下,如何使用grok模式或json解析此日志并获取ip,方法和严重性等字段
{"log":"2019-08-09 06:54:36,774 INFO 10.2.1.200 [09/Aug/2019:06:54:36 +0000] \"GET / HTTP/1.1\" 200 205 \"-\" \"HCELB/2.0\"\n","stream":"stderr","time":"2019-08-09T06:54:36.77499244Z"}
答案 0 :(得分:0)
感谢@gehbiszumeis的宝贵帮助,我自己动手解决了这个问题。对于将来需要的人
@type tail
path /var/log/containers/container-name-*.log
tag tag_name
read_from_head true
<parse>
@type multi_format
<pattern>
format json
</pattern>
</parse>
</source>
<filter tag_name>
@type parser
key_name log
reserve_data true
time_key time
time_format %Y-%m-%dT%H:%M:%S.%NZ
<parse>
@type grok
grok_failure_key grokfailure
<grok>
pattern %{TIMESTAMP_ISO8601:time} %{WORD:severity} %{GREEDYDATA:message}
</grok>
</parse>
</filter>
<filter tag_name>
@type record_transformer
remove_keys log,stream
<record>
type tag_name
</record>
</filter>
```