# Kibana 6.4 - Script to import dashboards, visualisation, search and index

**URL:** <https://discuss.elastic.co/t/kibana-6-4-script-to-import-dashboards-visualisation-search-and-index/147186>\
**Category:** Kibana\
**Created:** [September 4, 2018, 10:17am UTC](https://discuss.elastic.co/t/kibana-6-4-script-to-import-dashboards-visualisation-search-and-index/147186 "2018-09-04T10:17:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheSmartMonkey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thesmartmonkey/32/33965_2.png) [@TheSmartMonkey](https://discuss.elastic.co/u/TheSmartMonkey)\
**Post date:** [September 4, 2018, 10:17am UTC](https://discuss.elastic.co/t/kibana-6-4-script-to-import-dashboards-visualisation-search-and-index/147186/1 "2018-09-04T10:17:08Z")

</div>

I exported all the dashboard, visualisation, search and index I wanted into a json file and wath I want is to have a script that import this json file like the import button in the saved object area

 ![Screenshot%20from%202018-09-04%2011-45-11](https://us1.discourse-cdn.com/elastic/original/3X/c/9/c9271dfc0d1d0d052678a325109f2734db11c758.png)

I looked lot of topic related to that but most of all are out of date since the big change of version 6 on Mapping Types [https://logz.io/blog/removal-elasticsearch-mapping-types/](https://logz.io/blog/removal-elasticsearch-mapping-types/) and this post [https://github.com/elastic/kibana/pull/10858](https://github.com/elastic/kibana/pull/10858)

I don't know if it's still possible with curl commands I tried things like this

```auto
curl -XPOST http://localhost:9200/myindexname/type/_bulk?pretty=true -H 'Content-Type: application/json' --data-binary @all-kibana-visu-6-4.json

```

but with not lot of success

---

<div class="post-metadata">

**Author:** ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)\
**Post date:** [September 4, 2018, 12:49pm UTC](https://discuss.elastic.co/t/kibana-6-4-script-to-import-dashboards-visualisation-search-and-index/147186/2 "2018-09-04T12:49:53Z")

</div>

Hey @TheSmartMonkey, the endpoints for importing/exporting saved objects aren't publicly supported or documented yet, so while it's possible to reverse engineer the way that Kibana uses the internal APIs, they could potentially change between different versions.

With that being said, are you looking to export a Dashboard and all of it's related Visualizations, Searches and Index Patterns? If so, there's an internal API to do this which we use for loading Beats Dashboards which can be used similar to the following:

Export Dashboard

```auto
curl -k -XGET 'http://localhost:5601/api/kibana/dashboards/export?dashboard=<put your dashboard ID here>' -u elastic:changeme > export.json

```

Import Dashboard

```auto
curl -u elastic:changeme -k -XPOST 'http://localhost:5601/api/kibana/dashboards/import' -H 'Content-Type: application/json' -H "kbn-xsrf: true" -d @export.json

```

---

<div class="post-metadata">

**Author:** ![TheSmartMonkey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thesmartmonkey/32/33965_2.png) [@TheSmartMonkey](https://discuss.elastic.co/u/TheSmartMonkey)\
**Post date:** [September 5, 2018, 1:52pm UTC](https://discuss.elastic.co/t/kibana-6-4-script-to-import-dashboards-visualisation-search-and-index/147186/4 "2018-09-05T13:52:20Z")

</div>

Thanks a lot for you help @Brandon_Kobel I share my script with the community hope that it will help some poeple 😉  
If my script can be better don't hesitate to comment

I export each of my dashboard 1 by 1 with this command :

```auto
curl -k -XGET 'http://localhost:5601/api/kibana/dashboards/export?dashboard=<put your dashboard ID here>' -u elastic:changeme > export.json

```

Then I did a python script to add all my dashboard, then to fix a default index pattern and finally to add index pattern that are not used in my dashboards

```
import os

kibana_url="localhost:5601/api/"

add_dashboard="curl -u elastic:changeme -k -XPOST 'http://"+kibana_url+"kibana/dashboards/import' -H 'Content-Type: application/json' -H \"kbn-xsrf: true\" -d @"

add_index="curl -f -XPOST -H 'Content-Type: application/json' -H 'kbn-xsrf: anything' '"+kibana_url+"saved_objects/index-pattern/"

#dashboard1
os.system(add_dashboard+"dashboard1.json")

#dashboard2
os.system(add_dashboard+"dashboard2.json")

#dashboard3
os.system(add_dashboard+"dashboard3.json")

#set "*" as default index
id_default_index="87f3bcc0-8b37-11e8-83be-afaed4786d8c"

os.system("curl -X POST -H \"Content-Type: application/json\" -H \"kbn-xsrf: true\" -d '{\"value\":\""+id_default_index+"\"}' http://elastic:changeme@"+kibana_url+"kibana/settings/defaultIndex")

#Create index pattern
index_name = "index1-*"
os.system(add_index+index_name+"' '-d{\"attributes\":{\"title\":\""+index_name+"\",\"timeFieldName\":\"@timestamp\"}}'")

index_name = "index2-*"
os.system(add_index+index_name+"' '-d{\"attributes\":{\"title\":\""+index_name+"\",\"timeFieldName\":\"@timestamp\"}}'")

index_name = "index3-*"
os.system(add_index+index_name+"' '-d{\"attributes\":{\"title\":\""+index_name+"\",\"timeFieldName\":\"@timestamp\"}}'")

index_name = "index4-*"
os.system(add_index+index_name+"' '-d{\"attributes\":{\"title\":\""+index_name+"\",\"timeFieldName\":\"@timestamp\"}}'")

index_name = "index5-*"
os.system(add_index+index_name+"' '-d{\"attributes\":{\"title\":\""+index_name+"\",\"timeFieldName\":\"@timestamp\"}}'")
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 3, 2018, 1:52pm UTC](https://discuss.elastic.co/t/kibana-6-4-script-to-import-dashboards-visualisation-search-and-index/147186/5 "2018-10-03T13:52:29Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
