Export/Import Kibana Dashboards / Visualizations – REST API

Introduction

In our previous tutorial, we discussed about ELK/elastic stack which stands for Elasticsearch, Logstash and Kibana. Kibana is an open source analytics and visualization platform from ELK stack. You use Kibana to search, view, and interact with data stored in Elasticsearch. You can easily perform advanced data analysis and visualize your data in a variety of charts, tables, maps and create your own dashboards and visualizations.

In this article, will see how to migrate all Kibana dashboards and visualizations from one instance to another.

Export/Import Kibana Dashboards/Visualizations

There are two ways/methods to export/import the Kibana dashboards/visualizations:
1. Direct from Kibana UI
2. By Using export/import REST API

1. Direct from Kibana UI

Export:
First you need to export your current dashboards, searches and visualizations from your Kibana instance.
  1. Go to Kibana
  2. Click on Management
  3. Click on Saved Objects
  4. Once inside of “Edit Saved Objects” you can:
    1. Click on Export Everything
    2. Or select each Dashboards, Searches and Visualizations you need and click on Export

This will export a JSON file with all your dashboards, saved searches and visualizations. We recommend the full export because you will be sure that you have all your objects, if you were to export a single object, then it may not work if it is dependent on other objects.

Import :
  1. Go to Kibana
  2. Click on Management
  3. Next Click on Saved Objects
  4. Click on the Import button
  5. Browse the exported file
  6. You will then be prompted: “If any of the objects already exist, do you want to automatically overwrite them?” and you will be given the following options:
    1. No, prompt me for each one
    2. Yes, overwrite all

2. By Using export/import REST API

Export:
The following API exports all saved objects associated with and including the dashboard/visualization with id

GET api/kibana/dashboards/export?dashboard=<dashboard/visualization id>
E.g.
curl -X GET "http://localhost:5601/api/kibana/dashboards/export?dashboard=dashboard_id" > /tmp/export.json

Import:
The following API imports all saved objects associated with and including the dashboard/visualization with id

POST api/kibana/dashboards/import -d @"<path of exported json>"
E.g.
curl -X POST -H "Content-Type: application/json" -H "kbn-xsrf: true" "http://localhost:5601/api/kibana/dashboards/import" -d @/tmp/export.json


In Direct UI method,
If you export dashboard it doesn’t export its associated visualizations, we need to do it manually by selecting individuals.
In REST API Method, It exports everything including dashboards and its associated visualizations for given dashboard id.

Avinash Pawar

An automation enthusiast who presently working as DevOps Engineer.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle Plus

Avinash Pawar

An automation enthusiast who presently working as DevOps Engineer.