Splunk - 检查与我提供的任何字符串相同的日志

发布于 2025-01-11 17:06:19 字数 559 浏览 0 评论 0原文

我只想捕获包含“零容忍”、“晴天霹雳”、“改变与休息一样好”等值的日志。我已经尝试过这个,但它不起作用,它只捕获了第一个。 /description=(?零容忍 | 晴天霹雳 | 改变和休息一样好)

请记住,要检查的字符串需要由我提供。

  code = random05, description=bird in the hand is worth two in the bush, level=5
  code = random02, description=bolt from the blue, level=8
  code = random09, description=bunch of fives, level=3
  code = random05, description=A chain is only as strong as its weakest link, level=0
  code = random08, description=A change is as good as a rest, level=3```

There are more logs but they are not showing.

I want to capture only the logs that hold the values of "Zero tolerance", "bolt from the blue", "A change is as good as a rest" inside. I've tried with this but it doesn't work it only captures the first one. /description=(?Zero tolerance | bolt from the blue | A change is as good as a rest)

Have in mind that the strings to check needs to be provided by me.

  code = random05, description=bird in the hand is worth two in the bush, level=5
  code = random02, description=bolt from the blue, level=8
  code = random09, description=bunch of fives, level=3
  code = random05, description=A chain is only as strong as its weakest link, level=0
  code = random08, description=A change is as good as a rest, level=3```

There are more logs but they are not showing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温暖的光 2025-01-18 17:06:19

看起来您想要匹配 description 之后包含您指定的字符串之一的任何内容。然后您可以使用

description=(?<des>.*(?:Zero tolerance|bolt from the blue|A change is as good as a rest).*)

所以,这里,“des”组将尽可能匹配除了换行符之外的任何零个或多个字符,然后指定的字符串之一(注意 | 周围的空格被删除) ),然后再次是除换行符之外的尽可能多的任何零个或多个字符。

如果需要通过第一个逗号限制匹配,请将 . 替换为 [^,]

It looks like you want to match anything after description that contains one of the strings you specified. You can then use

description=(?<des>.*(?:Zero tolerance|bolt from the blue|A change is as good as a rest).*)

So, here, "des" group will match any zero or more chars other than line break chars as many as possible, then one of the specified strings (note the spaces around | are removed) and then again any zero or more chars other than line break chars as many as possible.

If you need to limit the match by the first comma, replace . with [^,].

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文