3

我正在尝试对匹配以下正则表达式的日志进行 Sumo Logic 搜索:

"Authorization \d+ for story is not voided. Story not removed"

也就是说,\d+由一个或多个数字组成,但它们究竟是什么并不重要。

基于搜索示例备忘单(https://help.sumologic.com/05Search/Search-Cheat-Sheets/General-Search-Examples-Cheat-Sheet),我尝试为此使用一种* | parse regex模式,但是不起作用:

在此处输入图像描述

我收到“在正则表达式中找不到捕获组”错误。不过,我实际上对捕获数字并不真正感兴趣,只是在我的搜索中匹配正则表达式。我怎样才能做到这一点?

4

1 回答 1

8

我设法让它以两种方式工作。首先,使用常规parse而不是parse regex

* | parse "Authorization * for story is not voided. Story not removed" as id |
count by _sourceHost | sort by _count

或者,当使用正则表达式时,它需要是一个命名组:

* | parse regex "Authorization (?<id>\d+) for story is not voided. Story not removed" |
count by _sourceHost | sort by _count
于 2018-11-30T19:20:58.593 回答