Splunk Enterprise Security

How to write query-rex to get table inside table data?

rashhvarikuti
New Member

How to write a rex query for table inside table for the below case

"studentInfo": {
"name": "Apple",
"id": "57",
"batch": "2006",
"subjects": {
"subject1": "English"
}
}

index=schoolIndex sourcetype=dev studentInfo | rex field=_raw "\"contentversions\":(?.*)}+" | spath input=message | table name id subjects

0 Karma

to4kawa
Ultra Champion
| makeresults 
| eval _raw ="\"studentInfo\": {
\"name\": \"Apple\",
\"id\": \"57\",
\"batch\": \"2006\",
\"subjects\": {
\"subject1\": \"English\"
}
}"
| rex max_match=0 "\"(?<fieldname>.*?)\": \"(?<fieldvalue>.*?)\""
| eval _raw=mvzip(fieldname,fieldvalue,"=")
| kv
| fields - _* field*
0 Karma

wmyersas
Builder

What do you want to rex out?

It's JSON - and should be coming at least mostly preparsed into Splunk

Are you sure something like the following won't work:

index=schoolindex sourcetype=dev studentInfo.subjects{}=*
| stats values(studentInfo.subjects) by studentInfo.id
0 Karma

rashhvarikuti
New Member

Yes, I tried similar way but it's getting no results(but results are there I tried "index= schoolindex sourcetype=dev jobId=8e62-71c72ccb3aec studentInfo" and getting data):

index= schoolindex sourcetype=dev jobId=8e62-71c72ccb3aec studentInfo. subjects{}=*
| stats values(studentInfo. subjects) by studentInfo.id

0 Karma
Get Updates on the Splunk Community!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...