[英]Logstash Filter Grok for custom log
I'm using Logstash
for the first time and I'm trying to map my logs with a grok filter, putting them on an ElasticSearch
and visualizing with Kibana
. 我是第一次使用
Logstash
,并且尝试使用Logstash
过滤器映射日志,将其放入ElasticSearch
并使用Kibana
可视化。
This is my current situation: 这是我目前的情况:
Filter 过滤
filter {
grok {
match => { "message" => "%{TIMESTAMP:timestamp} | %{WORD:trackingId} | %{WORD:request} | %{WORD:session} | %{IP:client} |
%{WORD:userId} | %{GREEDYDATA:message}" }
}
}
Log 日志记录
2017-03-21 11:11:54.731 | myApp_35 | myApp_35 | 69E59F4DACC314C0B11B1A8CEA87F9BB | 127.0.0.1 | | GET on URL [/api/customer] executed with success in [18555 us].
Apparently this is not working. 显然这是行不通的。 What am I doing wrong?
我究竟做错了什么?
Try this 尝试这个
%{TIMESTAMP_ISO8601:timestamp}%{SPACE}\|%{SPACE}%{WORD:trackingId}%{SPACE}\|%{SPACE}%{WORD:request}%{SPACE}\|%{SPACE}%{WORD:session}%{SPACE}\|%{SPACE}%{IP:client}%{SPACE}\|%{SPACE}%{DATA:userId}%{SPACE}\|%{SPACE}%{GREEDYDATA:message}
Based on OPs comment here is another regex with SPACE replaced by \\s* 根据OP的评论,这里是另一个正则表达式,其中SPACE替换为\\ s *
%{TIMESTAMP_ISO8601:timestamp}\s*\|\s*%{WORD:trackingId}\s*\|\s*%{WORD:request}\s*\|\s*%{WORD:session}\s*\|\s*%{IP:client}\s*\|\s*%{DATA:userId}\s*\|\s*%{GREEDYDATA:message}
I would recommend this site to test your grok regex: https://grokdebug.herokuapp.com/ 我会建议该网站测试您的希腊正则表达式: https ://grokdebug.herokuapp.com/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.