I try to write a python script that shall download the XML of a dashboard. After that some tokens shall be replaced and then I want to upload the XML.
Is there any method in the splunk SDK for python that can help?
With best regards,
I want to more about your requirement.
From where you will execute python script?? Means, are you executing a script from the same machine which runs Splunk OR other than Splunk machine??
It will run on the server in the end. But I am testing it on an external machine.
Thanks for the help!
I don't think Splunk Python SDK provide creation or updating of dashboard xml. If you want to do so you can use file operations of python for reading and writing dashboard xml file.
Can you please let me know the purpose of updating token of dashbard xml from python script ? So I can help out to get you into the right direction.
The purpose of this script is to update some reports. For this we want to copy the XML of a given dashboard and replace the tokens in it with actual values and update the saved searches. (I dont know if I explained this correctly, this part has been made by a co-worker).
Since now we had to copy the dashboard XML by hand via the "edit"-button.
We want to make this automatic (also we want to make the upload of the report automatic).
I also tried to use urllib2 to get the contents of the website but I always only get some
You can use SPLUNI REST API for creating/updating dashboards.
Create a python file & call SPLUNK API for creating/updating dashboards.
To create a new dashboard named "newdash":
curl -ku admin:changeme https://localhost:8089/servicesNS/admin/search/data/ui/views/ -d 'name=newdash' -d 'eai:data=<put your xml here>'
To edit an existing dashboard with the name "newdash":
curl -ku admin:changeme https://localhost:8089/servicesNS/nobody/search/data/ui/views/newdash -d 'eai:data=<put your xml here>'
Take a look at the keys that are returned from the endpoint, that should give you a pretty good idea of what you can change.
I hope this approach will be useful to you. Let me know any help need you for API.
One last question: How can I access a dashboard, that I own, but ist not private? The server response always say, that my dashboard would not exist, when it is no longer private.
How you are accessing dashboard? using splunk web UI or CURL command ??
I am accessing it with the following curl command:
curl -k -u USER:PASS https://URL:PORT/servicesNS/USER/APP/data/ui/views/DASHBOARDID -d "eai:data=Test"
(Capslock expressions are variables)
This works as long as the dashboard is private. When I change it so, that the whole app can see the dashboard, then the command does no longer work.