如何通过键值对关联两个 JSON 对象?

How to correlate two JSON objects via a key-value pair?

假设有数千个 JSON 条目,我想通过 key/value 对关联对象对。

条目 #44

{ speed: 55, distance: 18, time: 1481216486, color: red, }

条目#323

{ speed: 75, distance: 38, time: 1481216486, color: blue, }

搜索:sourcetype=test_drive (DO THE MAGIC) | eval first_distance=distance(#44) | eval second_distance=distance(#323) | table time first_distance(#323) second_distance(#44)

所以基本上我试图通过 key/value 找到一个条目对并使用另一个 key/value 对来创建 table.

您想在此处使用交易过滤器,http://docs.splunk.com/Documentation/Splunk/6.5.1/SearchReference/Transaction。这不会将您的 json 优雅地合并到 _raw 中,但它会使属性可供 query/chart 使用。

在这个例子中,我假设您想在 属性 之前合并事件,因为那是唯一匹配的字段。

sourcetype=test_drive (DO THE MAGIC) | eval first_distance=distance(#44) | eval second_distance=distance(#323) | transaction time | table time first_distance(#323) second_distance(#44)