Splunk Search

fetch one field value from json

rkishoreqa
Communicator

I need to fetch the 'sid' value from the below JSON.  

For that I prepared the below query, but it is not working. 

|rex field=_raw "sid\":\"(?P<sid>.[^\"\,\"]*)"
|stats count by sid

{
"sig_date": "11-SEP-2020 ",
"exe_date": "",
"sent_date": "13-JAN-2020",
"appr_date": "06-AUG-2020",
"comp_date": "08-SEP-2020",
"sid": "0ac00001789",
"visit": "Yes"
}
 
Can anyone please validate this query.
Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Amongst other things, you were missing a space. but it can be simplified to

rex "sid\":\s\"(?P<sid>[^\"]*)"

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Amongst other things, you were missing a space. but it can be simplified to

rex "sid\":\s\"(?P<sid>[^\"]*)"
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 ...