Splunk Search

How to retrieve one field from multiple responses?

greeshmak
Explorer

I'm trying to retrieve a field from a response:

here is the example:

response=[{"code":0,"count":1,"mobile":"123456",},{"code":0,"count":2,mobile":"67891011",},{"code":0,"count":1,"mobile":"234567"},{"code":0,"count":1,"mobile":"2765432"},{"code":0,"count":1,"mobile":"8901234"}]}

I want to extract the mobile number from all braces, If i use extraction using kvdelim and pairdelim,I'm not able to extract all values, it is returning only first mobile value.

Can someone suggest how to extract every mobile number from the response.

Thanks in advance.

0 Karma

gokadroid
Motivator

Since in you sample data, the mobile number comes always after keyword mobile however the " aren't always proper around it hence how about trying this:

your query to return the field response
| rex field=response max_match=0 "mobile(\D+)(?<mob>[\d]+)"
| table mob, response

This will create a multi-value field mob which will have all the mobile phone numbers which can be then used with mvexpand to tabulate or work upon something like below:

your query to return the field response
| rex field=response max_match=0 "mobile(\D+)(?<mob>[\d]+)"
| mvexpand mob
| table mob, response
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...