Splunk查询以从两个查询中获取不匹配的ID

问题描述 投票:0回答:1
Index=* sourcetype="publisher" namespace="app_1" | table ID message | where message="published"


Index=* sourcetype="consumer" namespace="app_1" | table ID message | where message="consumed"

我想通过比较两个查询来显示不匹配的ID,我该如何实现。

如果查询1提供了100条记录,查询2提供了90条记录,而所有90条记录都存在于查询1中,那么我想查看查询2中不存在的10条记录。

splunk splunk-query
1个回答
0
投票

有几种方法可以实现此结果。

下面计算每个ID的消费者和生产者事件的数量,然后显示仅发生一次的事件的ID。

index=* sourcetype="publisher" OR sourcetype="consumer" namespace="app_1" ID="*" | stats count by ID | where count<2

在下一个方法中,我们使用子搜索和联接。这样可以为您提供完整的活动,而不仅仅是ID。

index=* sourcetype="publisher" namespace="app_1" ID="*" | join type=outer ID [ search index=* sourcetype="consumer" namespace="app_1" ID="*" | eval does_match=1 ] | where isnull(does_match)
© www.soinside.com 2019 - 2024. All rights reserved.