Splunk Search

How to extract fields from JSON which is stored in another field?

pwunderlich
Engager

Hi

I am new here and I have an issue which is unsolvable for me. I hope some of you can help me.

The result of my Splunk search looks like the following:

2016-06-24 14:42:29,892 ERROR: eventId=3, incoming="{"eventId":5,"gameId":1,"networkId":1,"instanceId":1,"zoneId":1,"playerId":"123","date":14...}", transformed="null",....

Now I want to get access to the fields in the incoming field so that I can search the data later with R. For this reason, I need something like: extract pairdelim="," kvdelim=":", but I have absolutely no idea how I can do that.

Given that I am not a Splunk expert, it would be great if you can formulate your answer simple and understandable.

Thank you in advance for your help, and let me know if you need further information!

Tags (2)
0 Karma
1 Solution

somesoni2
Revered Legend

So, due to double quotes in the value of the incoming field, the default field extraction is not capturing the whole string. In this case, you'd have to setup a custom field extraction to do that. Give this a try

your base search | rex "incoming=\"(?<incoming>.+)\", transformed=" | spath incoming

View solution in original post

somesoni2
Revered Legend

So, due to double quotes in the value of the incoming field, the default field extraction is not capturing the whole string. In this case, you'd have to setup a custom field extraction to do that. Give this a try

your base search | rex "incoming=\"(?<incoming>.+)\", transformed=" | spath incoming

lshengfa
Engager

This is awesome. This is exactly what I need. I found out all my fields of json are extracted as "{" which is awkward.
Could you explain how your regex works if possible?
Thanks!!!

0 Karma

pwunderlich
Engager

Hi, thanks for you answer.

...| spath incoming does not work but ...| spath input=incoming works perfect!

0 Karma

somesoni2
Revered Legend

Does the field incoming in your event contains full json string that we see in the example? If yes, then use the spath option as suggested by @sundareshr below. If not, that needs to fixed (field extraction need to be set to capture full json string) before using spath.

0 Karma

pwunderlich
Engager

Does the field incoming in your event contains full json string that we see in the example?...

Yes it does, but the spath command does not work because the value of the incoming field is only { and not the whole JSON. I think the problem are the 2 quotation marks "{" but I am not sure.

0 Karma

sundareshr
Legend

Have you looked at the spath command http://docs.splunk.com/Documentation/Splunk/6.4.1/SearchReference/Spath

... | spath incoming | 
0 Karma

pwunderlich
Engager

Thank you for your answer, but spath does not working (see my comment above).

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...