Dashboards & Visualizations

How to create a dynamic table from JSON events

Biswadeep
Loves-to-Learn Everything

Hi,

I have an index that returns logging events in JSON format. I want to create a tabular dashboard which will dynamically update the JSON key-value pairs in rows and columns for visualization purposes. Any help would be highly appreciated.

index=log-1696-nonprod-c laas_appId=tsproid_qa.sytsTaskRunner laas_logId=CC6F5AA6-3813-11EE-AD8F-237241A57196

Event(the values change and it's dynamic): 

"groupByAction": "[{\"totalCount\": 40591, \"action\": \"update_statistics table\"}, {\"totalCount\": 33724, \"action\": \"reorg index\"}, {\"totalCount\": 22015, \"action\": \"job report\"}, {\"totalCount\": 10236, \"action\": \"reorg table\"}, {\"totalCount\": 7389, \"action\": \"truncate table\"}, {\"totalCount\": 3291, \"action\": \"defrag table\"}, {\"totalCount\": 2291, \"action\": \"sp_recompile table\"}, {\"totalCount\": 2172, \"action\": \"add range partitions\"}, {\"totalCount\": 2088, \"action\": \"update_statistics index\"}, {\"totalCount\": 2069, \"action\": \"drop range partitions\"}]"

 

Table should have "totalCount" and "action" as columns

 

Labels (1)
0 Karma

Biswadeep
Loves-to-Learn Everything

Can someone please help to fetch the other fields like groupByUser?

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Have you tried my suggestion on your actual events? (You don't need to include the lines which attempt to set up sample data based on the example you posted.)

0 Karma

Biswadeep
Loves-to-Learn Everything

Thank you so much. Finally I have my intended dashboard ready. Many thanks for your help 🙂

0 Karma

Biswadeep
Loves-to-Learn Everything

I am not looking for makeresults as that will be hard coded.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| spath groupByAction
| rex max_match=0 field=groupByAction "(?<group>\{[^\}]+\})"
| mvexpand group
| spath input=group
| table action totalCount
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Biswadeep,

these seems to be json logs so you sgould use a sourcetype for json logs, or at least use the "INDEXED_EXTRACTIONS = json" option in the props.conf so all the fields will be extracted and you can use them also in a table.

Otherwise you could use the spath command (https://community.splunk.com/t5/Splunk-Enterprise/spath-command/m-p/518343😞

index=log-1696-nonprod-c laas_appId=tsproid_qa.sytsTaskRunner laas_logId=CC6F5AA6-3813-11EE-AD8F-237241A57196
| spath
| table field1 field2 etc...

Ciao.

Giuseppe

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!

Automated Threat Analysis: Available in ES Premier

Automated Threat Analysis: Centralize and Accelerate Phishing Investigations in Splunk Enterprise ...

What’s New in Splunk AI: Volume 02

Welcome to the second edition of “What’s New in Splunk AI” where we look at the latest and greatest updates, ...

Best Practices: Splunk auto adjust pipeline queue

When you enable autoAdjustQueue in Splunk, maxSize should be understood as the queue size Splunk starts with ...