Splunk技术问询:找出仅关联event_A未关联event_B的ID
筛选仅关联event_A的ID(Splunk查询方案)
需求
从包含event_A和event_B的日志数据中,找出仅出现在event_A_recipients数组、从未在event_B_recipients里出现的ID,预期结果为id4。
可行的Splunk查询语句
index=<你的索引名称> eventType=event_A | spath output=id path=event_A.event_A_recipients{} | eval in_event_A=1 | append [ index=<你的索引名称> eventType=event_B | spath output=id path=event_B.event_B_recipients{} | eval in_event_B=1 ] | stats max(in_event_A) as in_event_A max(in_event_B) as in_event_B by id | where in_event_A=1 AND isnull(in_event_B) | table id
逻辑说明
- 用
spath的path=xxx{}语法解析JSON数组,将数组内的每个ID拆分为单独数据行,便于后续统计 - 通过
append子搜索合并两类事件的ID数据集 - 借助
stats按ID分组,标记每个ID在两类事件中的存在状态 - 最后通过
where筛选出仅在event_A中出现、未在event_B中出现的ID
内容的提问来源于stack exchange,提问作者Fulliautomatix
相关产品推荐
相关产品推荐

