Splunk Search

JSON Field Extraction and Charting

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

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
State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!