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
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

Splunk is officially part of Cisco

Revolutionizing how our customers build resilience across their entire digital footprint.   Splunk ...

Splunk APM & RUM | Planned Maintenance March 26 - March 28, 2024

There will be planned maintenance for Splunk APM and RUM between March 26, 2024 and March 28, 2024 as ...