Splunk Search

json parsing

onthakur
Engager

Hi

I have logs in below format, which is mix of delimiter (|) and json. now I want to extract statuscode and statuscodevalue and create table with columns _time,statuscodevalue,statuscode.

can someone please help me ?

2021-11-22 05:52:09.755 INFO - c.t.c.a.t.service.UserInfoService(101) - abcd | abcd-APP | /user-info | af4772c0-1fcd-4a82-858e-c2f7f0821724 | APP |
-| Response of validateAddress abcd Service: {
"headers" : { },
"body" : {
"baseError" : {
"code" : "3033",
"reason" : "User is unauthorized",
"explanation" : "Unauthorized"
}
},
"statusCode" : "UNAUTHORIZED",
"statusCodeValue" : 401
}

Labels (1)
Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| makeresults
| eval _raw="2021-11-22 05:52:09.755 INFO - c.t.c.a.t.service.UserInfoService(101) - abcd | abcd-APP | /user-info | af4772c0-1fcd-4a82-858e-c2f7f0821724 | APP |
-| Response of validateAddress abcd Service: {
\"headers\" : { },
\"body\" : {
\"baseError\" : {
\"code\" : \"3033\",
\"reason\" : \"User is unauthorized\",
\"explanation\" : \"Unauthorized\"
}
},
\"statusCode\" : \"UNAUTHORIZED\",
\"statusCodeValue\" : 401
}"



| eval _time=strptime(_raw,"%F %T.%Q")
| rex "(?ms)Service: (?<response>.*)"
| spath input=response statusCode
| spath input=response statusCodeValue
| table _time statusCodeValue statusCode
0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...