如何在 Elastic Stack 中为正则表达式编制索引?

How do I index regular expressions in Elastic Stack?

使用 ELK/Elastic Stack 进行日志管理,我想根据这样的日志行构建报告:

2018-01-31 11:50:00.212 Loading the user images took 234 ms 
2018-01-31 10:23:01.984 Loading the user images took 331 ms 
2018-01-31 10:12:41.323 Loading the user images took 512 ms 

因此,报告将采用字符串 Loading the user images took

然后正则表达式将提取数字 /took (\d+) ms/ 并构建图表或通知。

我该怎么做?也许这涉及以某种方式定义索引?

我会使用 logstash grok 过滤器。

https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html

使用此站点以用户友好的方式测试您的 grok 模式:

http://grokconstructor.appspot.com/do/match

我制作了一个将 ms 提取到 timeTaken 字段的模式:

%{GREEDYDATA}took %{NUMBER:timeTaken}

如果您需要更多数据,请使用在线页面进行测试并搜索 grok 模式。可视化在 Kibana 中完成。