All Apps and Add-ons

Create dashboards that has json as the dashboard content using API

dhirajshet
New Member

I recently came across creating the dashboards in SPLUNk that has json as the content (not XML) using Dashboard studio. But I am not able to create these dashboards using the rest end point that we have to create the dashboards with XML as it's data i.e 

splunk_server + '/servicesNS/' + app_author + '/Development/data/ui/views/
 
Please suggest me if there is way to automate creating these kinds of dashboards.
 
Thank you.
Labels (1)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@dhirajshet 

I hope you have used below API for creating  dashboard.

curl -ku admin:changeme https://localhost:8089/servicesNS/admin/search/data/ui/views/ -d 'name=newdash' -d 'eai:data=<put your xml here>'

 

For Deployment of Dashboards generated from Dashboard Studio, you still need to send XML which will have JSON definition. 

You can find the dashboard XML in same folder where old one are created. It will look like this.

Screenshot 2021-05-19 at 4.51.16 PM.png

You have to pass this XML as eai:data parameter in API.

 

Sample API Call:

 

curl -ku admin:admin123 https://localhost:8089/servicesNS/admin/search/data/ui/views/ -d 'name=newdash' -d 'eai:data=<dashboard version="2" theme="light"><label>Sample Dashboard Studio 1</label><description></description><definition><![CDATA[{"visualizations":{"viz_GnINCxpe":{"type":"viz.pie","options":{},"dataSources":{"primary":"ds_6EQA5AdB"}}},"dataSources":{"ds_6EQA5AdB":{"type":"ds.search","options":{"query":"| makeresults count=5 \n|  eval a=1 \n|  accum a \n| stats count by a"},"name":"Search_1"}},"defaults":{"dataSources":{"ds.search":{"options":{"queryParameters":{"latest":"$global_time.latest$","earliest":"$global_time.earliest$"}}}}},"inputs":{"input_global_trp":{"type":"input.timerange","options":{"token":"global_time","defaultValue":"-24h@h,now"},"title":"Global Time Range"}},"layout":{"type":"grid","options":{},"structure":[{"item":"viz_GnINCxpe","type":"block","position":{"x":0,"y":0,"w":1200,"h":400}}],"globalInputs":["input_global_trp"]},"description":"","title":"Sample Dashboard Studio"}]]></definition><assets><![CDATA[{}]]></assets></dashboard>'

Just try this and let me know if any issue.

 

 

Thanks
KV
▄︻̷̿┻̿═━一

If this reply helps you, an upvote would be appreciated.

dhirajshet1
Engager

Hi @kamlesh_vaghela 

That thing actually helped me. Thank you so much for your updates.

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@dhirajshet1 

Cool . You can accept the answer to close this question.

Thanks
KV
▄︻̷̿┻̿═━一


 

 

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!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...