Automate export of dashboards to folder
Author Edit:
I am no longer supporting this script.
Instead I recommend using PySense
Community Article: https://support.sisense.com/hc/en-us/community/posts/360042115574-PySense-a-Python-SDK-for-Sisense
GitHub: https://github.com/nathangiusti/PySense/
For questions or issued about PySense, comment on the community article or directly on the GitHub.
Cheers,
Nathan
----------------------
Have you ever wanted to automate the export of dashboards to a file folder? Well you can with the Sisense REST API.
This python script can be configured to export any number of dashboards to pdf, png, or dashfiles and it supports all query parameters. Just configure and schedule the program to run at the desired cadence.
A full list of options for the API calls is here.
To run on a schedule, add the call to a bat file and use your windows scheduler to set the file to run at set times.
In the zip file linked you will find
backup_dashboards.py - The python script that does the heavy lifting. This requires the installation of the Python 3.0+ environment.
BackupDashboards.md - A readme with further information on how to use the script
example_dash.yaml - An example config for exporting dash files
example_png.yaml - An example config for exporting png files
example_pdf.yaml - An example config for exporting pdfs files
Download: BackupDashboards.zip
Update 07/19/2019: Host is now configurable. Better error logging. See readme for more info.
Update 07/18/2019: Program now supports pulling of dashboards via API. See readme in zip file for details.
-
Hello!
Thank you for the script. Could you please advise how to configure it for SSL connection? I got:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "backup_dashboards.py", line 308, in <module>
main()
File "backup_dashboards.py", line 277, in main
headers = authenticate(host, data_loaded['authentication'])
File "backup_dashboards.py", line 29, in authenticate
resp = requests.post('{}/api/v1/authentication/login'.format(host), data=data)
File "/usr/lib/python3/dist-packages/requests/api.py", line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/lib/python3/dist-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 520, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 630, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 506, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='*****', port=443): Max retries exceeded with url: /api/v1/authentication/login (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),))Tried to use the met hods here but stuck:
https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error
Best regards,
Andrey
-
Hey Andrey Zhekov
You can try the fixes here: https://medium.com/@moreless/how-to-fix-python-ssl-certificate-verify-failed-97772d9dd14c
Or you can try using our new PythonSDK to write your own backup script.
https://support.sisense.com/hc/en-us/community/posts/360042115574-PySense-a-Python-SDK-for-Sisense
Let me know how it goes.
Nathan
-
Hello Nathan,
The first fix didn't help. I found that Python 3.6+ has issue with TLS 1.2 SSL connections and TLS v1.2 is now enforced in Sisense v.8.1.3 which is our current server version.
https://github.com/docker-library/python/issues/429
We will try PythonSDK soon.
Best regards,
Andrey
-
Hi Andrey,
To get around the TLS issue I installed certifi -- https://pypi.org/project/certifi/. If that still doesn't work you can append your root CA from the certificate to the certifi cacerts.pem file (run certifi.where() to check the location).
-
Thanks for the script. Could you please advise for error below:
File "C:\Users\rabell\Desktop\SisenseBackUp\backup_dashboards.py", line 302, in <module>
main()
File "C:\Users\rabell\Desktop\SisenseBackUp\backup_dashboards.py", line 271, in main
headers = authenticate(host, data_loaded['authentication'])
File "C:\Users\rabell\Desktop\SisenseBackUp\backup_dashboards.py", line 22, in authenticate
data = {'username': authentication_params['username'], 'password': authentication_params['password']}
TypeError: string indices must be integers -
Hey Ru,
I am no longer supporting this script.
Instead I recommend using PySense
Community Article: https://support.sisense.com/hc/en-us/community/posts/360042115574-PySense-a-Python-SDK-for-Sisense
GitHub: https://github.com/nathangiusti/PySense/
You can use this to get all of your dashboards and export them to dash, png, or csv. See the documentation and training for details.
Cheers,
Nathan
Please sign in to leave a comment.
Comments
7 comments