Splunk 查询从日志数据中提取字段

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

我的 Splunk 记录了类似

[user name] [traceid] ldap authentication { “status” : “success” , “username”: “123”} MULTIEXCEPTION some text….

的内容

我正在尝试 Splunk 查询,该查询以表格格式给出结果。有任何查询建议吗?

Status  username 
Success 123
Fail     234
splunk splunk-query
1个回答
0
投票

正如 @rex 所写,使用

rex
命令从事件中提取字段。然后使用(惊喜!)
table
命令将结果以表格格式显示。

index=foo
``` Extract the status field ```
``` Triple escapes are needed because of multiple layers of processing ```
| rex "status\\\"\s*:\s*\\\"(?<status>[^\\\"]+)"
``` Extract the username field using a separate command for order-independence ```
| rex "username\\\"\s*:\s*\\\"(?<username>[^\\\"]+)"
| table status username
© www.soinside.com 2019 - 2024. All rights reserved.