Our event log has request and response. Request and response body can either be a json object or json array. I need to extract resquest.body and response.body to construct a field "httpdetails" which is a string . How can i achieve this using single spath function. example of log events : {
"message": {
"request": {
"body": {}
},
"response": {
"body": [
{
"id": "85118db6-2d5c-6bb0-ff67-5bc9ef5d4a1f",
"createdon": "2021-07-08T00:37:02.512Z"
}
]
}
}
} {
"message": {
"request": {
"body": {
"$limitafter": "2021-07-08T20:08:29.983Z"
}
},
"response": {
"statuscode": 200,
"body": {
"count": "22"
}
}
}
} Splunk query : | spath output=response_data message.response.body | spath output=request_data message.request.body | eval request_data=if(isnull(request_data) , NULL , request_data) | eval response_data=if(isnull(response_data), NULL, response_data) | eval httpdetails="\n"+request_data+"\n-----------------Response---------------\n"+response_data, httpdetails = split(httpdetails,"\n") | eval details=if(isnotnull(httpdetails), httpdetails, details) After running this query "httpdetails" is shown below. Here response_data for first log event is coming as NULL instead of object array. How can I fix this??
... View more