Sysdig Documentation

Save and Restore Dashboards with Scripts

Sysdig Monitor provides users the ability to save existing dashboards to a locally controlled file, and create new dashboards identical to the ones previously saved. This can be done via Sysdig's Python client library example scripts. The save script stores all current dashboards for the active account in a .zip archive, while the restore script adds all dashboards in the archive to the list of dashboards.

The restore script does not have to target the same account as the save script. This allows dashboards to be saved from one user and restored to multiple users.

Warning

Restoring dashboards will not override the user's existing dashboards. Instead, new dashboards will be added to the list.

If this script is used in a strictly backup/restore capacity, dashboards will need to be deleted manually from the account, either before or after the restore action is completed.

Prerequisites

Saving and restoring the scripts has the following prerequisites:

  • Python 2.x (2.7.x)

  • pip version 1.3 or later.

    Note

    pip is installed as part of the Python package for versions 2.7 and later.

  • virtualenv (recommended)

The library and example scripts are available in the Sysdig GitHub repository: https://github.com/draios/python-sdc-client.

Download the Scripts

To configure the local environment for the scripts:

  1. Either download a .zip archive of the python client from the repository and unpack it or clone the repository:

    sysdig@user:~$ git clone https://github.com/draios/python-sdc-client.git
  2. In a terminal, navigate to the directory.

  3. Configure the Python environment as necessary.

    Note

    If you are unfamiliar with Python, Sysdig recommends setting up via pip & virtualenv:

    sysdig@user:~$ mkdir -p ~/workingdir/venv # declare where you want all python tools installed
    sysdig@user:~$ sudo virtualenv ~/workingdir/venv  # prepare the workspace -- this may download several things
    sysdig@user:~$ source ~/workingdir/venv/bin/activate  # cause all python tools to use this workspace from now on
    (venv) $  # at this point the prompt reminds us we're in the virtual environment
    (venv) $  pip install .    # install the sdcclient library into the venv

The sdcclient module is now available to Python.

Save All Dashboards with a Python Script

To save the dashboards:

  1. In a terminal, access the virtual environment set up in Download the Scripts.

  2. Run the script, replacing API_TOKEN with the API token for the relevant user, and SAVED_DASHBOARDS.ZIP with the desired name of the zip file:

    (venv) $ sudo 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

    See Retrieve the Sysdig API Token for details.

Restore Dashboards with a Python Script

To restore dashboards from a .zip archive

  1. In a terminal, access the virtual environment set up in Download the Scripts.

  2. Run the script, replacing API_TOKEN with the API token for the relevant user, and SAVED_DASHBOARDS.ZIP with the correct zip file:

    (venv) $ sudo python examples/restore_dashboards.py API_TOKEN SAVED_DASHBOARDS.ZIP
    Dashboards pushed.
    (venv) user@server:~/python-sdc-client$