Splunk Search

JSON extraction needed

mbasharat
Builder

Hi. I have below raw event/s.

Highlighted Syntax:
{ [-]
   body{"isolation": "isolation","device_classification": "Network Access Control","ip": "1.2.3.4", "mac": "Unknown","dns_hn": "XYZ","policy": "TEST_BLOCK","network_fn": "CounterACT Device","os_fingerprint": "CounterACT Appliance","nic_vendor": "Unknown Vendor","ipv6": "Unknown",}
   ctupdatenotif
   eventTimestamp1739913406
   ip1.2.3.4
   tenant_idCounterACT__sample

}

Raw Text:
{"tenant_id":"CounterACT__sample","body":"{\"isolation\": \"isolation\",\"device_classification\": \"Network Access Control\",\"ip\": \"1.2.3.4\", \"mac\": \"Unknown\",\"dns_hn\": \"XYZ\",\"policy\": \"TEST_BLOCK\",\"network_fn\": \"CounterACT Device\",\"os_fingerprint\": \"CounterACT Appliance\",\"nic_vendor\": \"Unknown Vendor\",\"ipv6\": \"Unknown\",}","ctupdate":"notif","ip":"1.2.3.4","eventTimestamp":"1739913406"}

I need below fields=value extracted from each event at search time. It is a very small dataset:

isolation=isolation
policy=TEST_BLOCK
ctupdate=notif
ip=1.2.3.4
ipv6=Unknown
mac=Unknown
dns_hn=XYZ
eventTimestamp=1739913406

Thank you in advance!!!

Labels (4)
0 Karma
1 Solution

livehybrid
SplunkTrust
SplunkTrust

Hi @mbasharat 

Add "| spath input=body" to your SPL - this will then extract the fields within the body JSON key as keyval fields in your results.

Please let me know how you get on and consider accepting this answer or adding karma this answer if it has helped.
Regards

Will

View solution in original post

0 Karma

mbasharat
Builder

Thank you @livehybrid !!!!! I knew I was dosing off at the end of the day.... LOL

0 Karma

livehybrid
SplunkTrust
SplunkTrust

Hi @mbasharat 

Add "| spath input=body" to your SPL - this will then extract the fields within the body JSON key as keyval fields in your results.

Please let me know how you get on and consider accepting this answer or adding karma this answer if it has helped.
Regards

Will

0 Karma
Get Updates on the Splunk Community!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...