Save and Restore Dashboards with Scripts
Sysdig Monitor allows a user to save all existing dashboards to a locally controlled file and to create new dashboards identical to the saved ones. This is done using two of the Sysdig's Python example scripts:
download_dashboards.py:
Stores all current dashboards for the active account in a .zip archive of JSON objects. Each JSON object in the archive corresponds to a dashboard. The dashboard JSON objects are named after the corresponding dashboard IDs.restore_dashboards.py:
Import the JSON objects in the archive as dashboards and add them to the list of dashboards.Restore_dashboards.py
does not have to target the same account asdownload_dashboards.py
. This allows dashboards to be saved from one user account and restored to multiple user accounts. If this script is used in a strictly backup/restore capacity, manually delete the dashboards from the account, either before or after the restore action is completed.
Note
Restoring dashboards will not override the user's existing dashboards. Instead, new dashboards will be added to the list.
Prerequisites
Follow the instructions in Get Started with the SDC Client, and do the following:
Install the Python client.
Instantiate the library classes.
Retrieve the API token needed to use the functions.
Save All Dashboards with download_dashboards.py
To save the dashboards:
In a terminal, access the virtual environment set up in Get Started with the SDC Client.
Note that you will have obtained your API token.
Run the script:
$ python examples/download_dashboards.py API_TOKEN SAVED_DASHBOARDS.ZIP Dashboard name: JVM, # Charts: 5 Finished writing dashboard data in zip format to SAVED_DASHBOARDS.ZIP
Replace
API_TOKEN
with the API token for the relevant user. ReplaceSAVED_DASHBOARDS.ZIP
with the desired name of the zip file.Ensure that all current dashboards in Sysdig Monitor were downloaded locally as JSON objects in a .zip file.
Restore Archived Dashboards with restore_dashboards.py
To restore dashboards from a .zip archive:
In a terminal, access the virtual environment set up in Getting Started with SDCClient
Note that you will have obtained your API token.
Run the script:
$ python examples/restore_dashboards.py API_TOKEN SAVED_DASHBOARDS.ZIP Dashboards pushed. $ user@server:~/python-sdc-client$
Replace
API_TOKEN
with the API token for the relevant user, andSAVED_DASHBOARDS.ZIP
with the correct zip file.The archived dashboards will be added to the user's dashboard list in Sysdig Monitor.
If necessary, manually delete any duplicates created.
Note
In April, 2019, Sysdig Monitor SaaS upgraded all dashboards from V1 to V2. If users have archived dashboards before this date and would like to restore them, it is necessary to update the archived JSON objects to match the new schema. See Migrate Saved Dashboards from V1 to V2.