logstash过滤kafka输出数据
来源:11-7 pipeline配置简介

酒酿丸子不甜
2020-05-13
{
"@version" => “1”,
“message” => “{\n “timestamp”:“2020-05-13 14:39:53.006”,\n “app”: “APP_NAME_IS_UNDEFINED”,“thread”: “http-nio-8009-exec-2”, “logLevel”: “INFO”, “message”: “{‘GTime’:‘194’, ‘IndicatorStatus’:‘0’, ‘ClassName’:‘com.unicom.admin.controller.DictController’, ‘InterfaceName’:‘SysDictQuery’, ‘ErrorContent’:‘null’, ‘ServerIp’:‘127.0.0.1’, ‘RequestUrl’:’/system-management/sysDict/’, ‘ServerName’:‘system-management’}”,“logger”:“inputkafka”\n }\n”,
"@timestamp" => 2020-05-13T06:39:53.083Z
}
kafka输出是这个格式的数据,我怎么用logstash将数据过滤成一个json数据
ps:需要message下的timestamp,thread,logLevel ,GTime等等的数据
1回答
-
两种方法:
一种是用正则匹配,就是 grok filter
一种是用 logstash json filter,把 message 用 json 做 decode,然后把你需要的字段提取出来。
https://www.elastic.co/guide/en/logstash/current/plugins-filters-json.html
json filter 会容易一些
112020-05-15
相似问题
回答 1
回答 1