All Apps and Add-ons

Web Tools Add-on: how do I extract the following fields from the json (or break the json into multiple events)?

lennys26
Communicator

When using the curl get, I am receiving a json response, however with no field extraction. SPATH is not working and, neither are my manual regexes.

I would like the extracted fields from the json, or the json broken into multiple events.

Am I missing something?

A simple, single value result is:

{ "origin" : "NYC", "currency" : "USD", "results" : [ { "destination" : "AGP", "departure_date" : "2018-09-09", "return_date" : "2018-09-17", "price" : "742.85", "airline" : "IB" } ] }

A multi value event example is:

{ "origin" : "NYC", "currency" : "USD", "results" : [ { "destination" : "AGP", "departure_date" : "2018-09-09", "return_date" : "2018-09-17", "price" : "742.85", "airline" : "IB" }, { "destination" : "AGP", "departure_date" : "2018-09-09", "return_date" : "2018-09-18", "price" : "742.85", "airline" : "IB" }, { "destination" : "AGP", "departure_date" : "2018-09-09", "return_date" : "2018-09-19", "price" : "742.85", "airline" : "IB" }, { "destination" : "AGP", "departure_date" : "2018-09-09", "return_date" : "2018-09-13", "price" : "746.85", "airline" : "IB" }, { "destination" : "AGP", "departure_date" : "2018-09-09", "return_date" : "2018-09-14", "price" : "746.85", "airline" : "IB" }, { "destination" : "AGP", "departure_date" : "2018-09-09", "return_date" : "2018-09-16", "price" : "931.78", "airline" : "IB" }, { "destination" : "AGP", "departure_date" : "2018-09-09", "return_date" : "2018-09-11", "price" : "959.92", "airline" : "BA" }, { "destination" : "AGP", "departure_date" : "2018-09-09", "return_date" : "2018-09-10", "price" : "1062.46", "airline" : "AA" }, { "destination" : "AGP", "departure_date" : "2018-09-09", "return_date" : "2018-09-15", "price" : "1195.56", "airline" : "IB" }, { "destination" : "AGP", "departure_date" : "2018-09-09", "return_date" : "2018-09-12", "price" : "1394.32", "airline" : "AT" } ] }
0 Karma
1 Solution

jkat54
SplunkTrust
SplunkTrust

Try this:

... | makemv delim=“, “ curl_response | mvexpand curl_response | table curl_response

View solution in original post

0 Karma

christianmuelle
Explorer

Hey there, i have a issue like this, I get a json back without field extraction

My search is:
"index=wifi sourcetype=netxml
| table wireless-network.BSSID
| dedup wireless-network.BSSID
| curl method=POST uri=https://www.googleapis.com/geolocation/v1/geolocate?key=APIKEY"

The responce looks like:
{ "location": { "lat": 48.2453772, "lng": 11.6262551 }, "accuracy": 1186.0 }

Has anyone a hind for me? Thx

0 Karma

jkat54
SplunkTrust
SplunkTrust

You can create your own question and reference this post.

0 Karma

jkat54
SplunkTrust
SplunkTrust

Try this:

... | makemv delim=“, “ curl_response | mvexpand curl_response | table curl_response

0 Karma

lennys26
Communicator

@jkat54 - This did work and I ended up with:

...| makemv delim=", " "results{}" | mvexpand results{} | table results{}*

Thanks.

jkat54
SplunkTrust
SplunkTrust

@lennys26 did this help?

0 Karma

jkat54
SplunkTrust
SplunkTrust

Did you try the xmlkv search command or xpath?

Can you share your search?

0 Karma

nadlurinadluri
Communicator

You might want to add the below props.conf in the UF ;
props.conf

INDEXED_EXTRACTIONS = JSON
KV_MODE = none

That way splunk will extract the file as a json

0 Karma

lennys26
Communicator

@nadlurinadluri - Normally this is where i would look, however this data is being pulled via REST CURL on the SPL query line, therefore there is no UF (or props).

0 Karma

nadlurinadluri
Communicator

My bad, didn`t realize that!! Will wait for someone to answer this 🙂

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...