Splunk Search

JSON Field Extraction and Charting

sarnathkj
Explorer

I have a sample JSON just like this.

{"Domain":"DotComMobile","Metrics":"city","Brooklyn":782,"Bronx":450,"New York":411,"Philadelphia":287,"Chicago":254,"Washington":210,"Silver Spring":176,"Houston":148,"Los Angeles":140,"Boston":133}

I want to chart the values corresponding to cities in a pie chart similar to the picture attached. How would I accomplish this?

spath extracts the JSON as individual key value pairs but not able to move further from there to creating pier chart of the cities in the JSON.

0 Karma

cpetterborg
SplunkTrust
SplunkTrust

Here is one way to get the pie chart to work. It may not be the best, but it will at least get you started. It is a run-anywhere search that you can just paste into the search bar and it will show you the results of the data that you have provided:

| makeresults
| eval data="{\"Domain\":\"DotComMobile\",\"Metrics\":\"city\",\"Brooklyn\":782,\"Bronx\":450,\"New York\":411,\"Philadelphia\":287,\"Chicago\":254,\"Washington\":210,\"Silver Spring\":176,\"Houston\":148,\"Los Angeles\":140,\"Boston\":133}"
| spath input=data
| fields - data, Domain, _time, Metrics
| fieldsummary
| fields field max
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...