【发布时间】:2020-09-30 10:26:49
【问题描述】:
我能够在 splunk 仪表板中获取多个事件(api 的日志),如下所示
事件 1:
{ "corrId":"12345", "traceId":"srh-1", "apiName":"api1" }
事件 2:
{ "corrId":"69863", "traceId":"srh-2", "apiName":"api2" }
事件 3:
{ "corrId":"12345", "traceId":"srh-3", "apiName":"api3" }
我想通过提供 apiName 并基于检索到的 corrId 值构建 splunk 搜索查询,从一个事件(api 日志)动态检索 corrId(例如:-“corrId”:“12345”),这意味着它将拉所有包含相同corrId ("corrId":"12345") 的事件日志。
输出
在上述情况下,预期结果如下所示
事件 1:
{ "corrId":"12345", "traceId":"srh-1", "apiName":"api1" }
事件 3:
{ "corrId":"12345", "traceId":"srh-3", "apiName":"api3" }
我是 splunk 的新手,请在这里帮助我,如何通过提供 apiName 等其他字段来动态获取 "corrId":"12345" 并基于此构建 Splunk 搜索查询。
我已经尝试如下,但没有运气。
index = "test_srh source=policy.log [ search index = "test_srh source=policy.log | rex field=_raw "apiName":|s+"(?[^"]+)" | search name="api1" | table corrId]
此查询仅提供 event-1 日志,但我们需要包含相同 corrId ("corrId":"12345") 的所有其他事件。在这里感谢快速帮助。
【问题讨论】:
标签: splunk splunk-query