我想找到一个字符串(驱动因子),如果找到了,只有找到另一个具有相同x-request-id的字符串,然后从中提取一些细节。
x-request-id=12345 "InterestingField=7850373" [this one is subset of very specific request]
x-request-id=12345 "veryCommonField=56789" [this one is a superSet of all kind of requests]
我尝试过的事情:
index=myindex "InterestingField" OR "veryCommonField"
| transition x-request-id
但是上面的问题是这个查询也加入了所有那些只有veryCommonField的请求。 我想避免加入,因为它们的性能相当低。
我需要什么: 列出InterestingField,veryCommonField
示例: 下面代表各种请求的开始。一天之内,我们就会收到数千个此类请求。
index=myIndex xrid=12345 "Request received for this. field1: 123 field2: test"
在上述所有要求中,低于100的类别。
index=myIndex xrid=12345 "I belong to blahBlah category. field3: 67583, field4: testing"
我不想搜索超过1000k的超集,而只搜索100个匹配的请求。因为随着时间跨度的增加,此搜索查询将花费很长时间。
答案 0 :(得分:1)
如果我了解您的用例,以下内容可能会有所帮助。
使用统计信息
index=myindex "InterestingField" OR "veryCommonField" | stats values(InterestingField), values(veryCommonField) by x-request-id
使用子搜索
index=myindex [ index=myindex InterestingField=* | fields x-request-id | format ]
根据匹配InterestingField
的结果数,您也可以使用map
,https://docs.splunk.com/Documentation/Splunk/8.0.3/SearchReference/Map
index=myindex InterestingField="*" | map maxsearches=0 "search index=myindex x-request-id=$x-request-id$ | stats values(InterestingField), values(veryCommonField) by x-request-id"
如果您提供了更详尽的示例事件,我们可以为您提供进一步的帮助。