Splunk Search

How to extract json fields from json inside single quotes?

Alanshiau717
New Member

Hey I am having difficulties trying to extract fields from my splint logs. They are in the format of

’{“field”: “value1”, “field2”: “value2”}’  I’ve tried using spath but it doesn’t seem to work. I think the issue is that the json object is enclosed in single quotes so splunk doesn’t recognise it as json. 

Labels (2)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

One solution is to rex the json out.  Assuming that the sample data you give is _raw:

| rex "'(?<jfield>[^']+)"
| spath input=jfield

 

0 Karma
Get Updates on the Splunk Community!

Splunk MCP & Agentic AI: Machine Data Without Limits

  Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization ...

Finding Based Detections General Availability

Overview  We’ve come a long way, folks, but here in Enterprise Security 8.4 I’m happy to announce Finding ...

Get Your Hands Dirty (and Your Shoes Comfy): The Splunk Experience

Hands-On Learning and Technical Seminars  Sometimes, you just need to see the code. For those looking for a ...