我想根据以下搜索创建警报:
这是我的想法(删除了霸王龙行中的其他固定字符串):
index=* "a.string"
| rex field=_raw "(?P<xx>\S+) (?P<yy>\S+)"
| map maxsearches=100 search="search index=* "another.string" AND $xx$
| rex field=_raw (?P<zz>\S+)"
| eval temp_xx=\"$xx$\"
| eval temp_yy=\"$yy$\""
| eval xx=temp_xx
| eval yy=temp_yy
| fields - temp_xx
| fields - temp_yy
| table xx, yy, zz
一切正常,包括我在最终搜索结果表中得到了 xx、zz 的值。
但是,最终搜索结果表 yy 始终为空。
单击 Splunk webgui 上的“事件”选项卡时,我可以看到 xx、yy、zz 的所有多个值,这意味着我的两次搜索都成功了。
但是为什么我在最终的搜索结果表中无法获取到 yy 的值,如何解决?
您可以尝试这样的事情(假设您在每个事件中都有一个像
hostname
这样的公共字段):
index=ndx sourcetype=srctp ("a.string" OR "another.string")
| rex field=_raw "some text that exists in events with a.string (?<xx>\S+) (?<yy>\s+)"
| rex field=_raw "other text found with another.string (?<zz>\S+)"
| fields xx yy zz hostname
| stats values(*) as * by hostname
| where isnotnull(xx) AND isnotnull(zz)