Splunk - 如何将同一对象的不同类型的新旧日志结果合并到一个搜索中

问题描述 投票:0回答:1

我正在日志中跟踪用户。我曾经在 info.userData 上保存一个包含用户名的字符串。后来我将 userData 转换为一个对象,该对象在 info.userData.id 中保存相同的用户名。意味着 userData 变成了一个对象,不再是一个字符串。 现在,我正在尝试创建一个搜索,返回所有唯一用户的列表。

我尝试搜索旧方法和新方法,然后对结果进行重复数据删除以获得一个列表,但无论我尝试什么,我都无法做到这一点。请帮忙:(

示例代码:(显然已更改为我的索引)

index=<index>
| eval old = [search index=<index> | rename info.userData as username_old | dedup username_old | return $username_old]
| eval new = [search index=<index> | rename info.userData.id as username_new | dedup username_new | return $username_new]
| mvcombine delim="," old new AS username | dedup username
| table username
splunk splunk-query splunk-formula splunk-calculation
1个回答
0
投票

有一个更简单的方法。由于任何事件都会有

info.userData
info.userData.id
,我们可以使用
coalesce
函数将用户名设置为存在的用户名。

index=foo
| eval username = coalesce(info.userData, info.userData.id)
| dedup username
| table username
© www.soinside.com 2019 - 2024. All rights reserved.