Importing and Exporting Dashboards
In order to make it possible to deploy a single dashboard in multiple WSO2 product instances (e.g., multiple SP instances, other SP-based Analytics profiles such as EI Analytics, etc.), WSO2 SP allows dashboards to be imported and exported.
Exporting dashboards
A dashboard can be exported as a JSON file from the Dashboard Portal or via REST API.
Exporting dashboards from the Dashboard Portal
To export a dashboard as a JSON file from the Dashboard Portal, follow the steps below:
- Start and access the Dashboard Portal as described in Visualizing Data.
- Find the dashboard you want to export in the list of dashboards displayed. Then click its menu icon.
- Click Export in the menu that is displayed.Â
The dashboard is exported as a JSONÂ file to your default location (based on your operating system and browser settings).
Exporting dashboards via REST API
Exporting dashboards is carried out via a REST API that can be invoked via the following curl command. This generates a JSON file that can be imported to another SP-based WSO2 product.
curl -u <USERNAME>:<PASSWORD> -o '<DASHBOARD_ID>.json' -k 'https://localhost:9643/portal/apis/dashboards/<DASHBOARD_ID>/export'
e.g., the following curl exports a dashboard named ei-analytics
.
curl -u admin:admin -o 'ei-analytics.json' -k 'https://localhost:9643/portal/apis/dashboards/eianalytics/export'
This export generates the following JSON file.
{ dashboard: { ... }, widgets: { generated: [ ... ], custom: [ ... ] } }
The fields included in the dashboard structure in this generated file are as follows:
Field | Description |
---|---|
dashboard | This field contains the definition of the dashboard, including the dashboard metadata such as the dashboard name, URL and page structures including widgets. |
widgets.generated | This field contains the definitions of widgets generated via the Widget generation wizard. |
widgets.custom | This contains the list of the names of the custom widgets contained in the dashboard. |
Importing dashboards
Once a dashboard is exported from one SP-based WSO2 product as explained in Exporting Dashboards, it can be imported into the Dashboard portal of any other SP-based WSO2 product instance. This is done by copying the generated JSON file and placing it in the <SP_HOME>/wso2/dashboard/resources/dashboards
directory of the required SP-based WSO2 product pack.
e.g., If the ei-analytics.json
generated in the above example is imported to another WSO2 SP instance, its path in the SP pack is <SP_HOME>/wso2/dashboard/resources/dashboards/ei-analytics.json
.
When the SP server is started, it picks the JSON files located in the <SP_HOME>/wso2/dashboard/resources/dashboards
 directory and copies those dashboards and widgets into the relevant tables in the underlying DASHBOARD_DB
database. Once the dashboard is successfully imported, the following messages are logged in a file named carbon.log in the <SP_HOME>/wso2/dashboard/logs
directory.
... [2018-09-17 10:41:52,094] INFO {org.wso2.carbon.dashboards.core.internal.DashboardImporter} - Successfully imported dashboard 'eianalytics' from '<SP_HOME>/wso2/dashboard/resources/dashboards/ei-analytics.json'. ...
When a dashboard is successfully imported, the .imported
suffix is added to the name of the JSON file (e.g., ei-analytics.json.imported
). Â This prevents the same dashboard from being imported more than once (because importing more than once can result in overwriting any custom changes you may have made via the Dashboard Designer).