首页 > 解决方案 > Splunk 查询从 JSON 单元格中获取字段

问题描述

splunk 查询输出一个表,其中一个列具有这些类型的 json 提供此输出的查询部分是details.ANALYSIS

{"stepSuccess":false,"SR":false,"propertyMap":{"Url":"https://example.com","ErrCode":"401","transactionId":"7caf34342524-3d232133da","status":"API failing with error code 401"}}

我想编辑我的 splunk 查询,以便我只Url在同一列中而不是这个 json。

这是我正在使用的 splunk 查询

|dbxquery connection="AT" query="select service.req_id, service.out,details.ANALYSIS from servicerequest service,SERVICEREQUEST_D details where service.out like 'XYZ is%'  and service.row_created > sysdate-1 and service.SERVICEREQUEST_ID = details.SERVICEREQUEST_ID and  details.ANALYSIS_CLASS_NAME = 'GetProduction' " shortnames=0 maxrows=100000001

我尝试使用 details.ANALYSIS.propertyMap.Url 但它会引发错误。

标签: sqljsonsplunksplunk-querysplunk-dbconnect

解决方案


您可能可以使用spath从 details.ANALYSIS 中提取字段

尝试以下提取所有字段

| spath field="details.ANALYSIS"

或者这只是针对您所追求的 url 字段

| spath field="details.ANALYSIS" path="propertyMap.Url"


推荐阅读