# Exporting Dashboards with script

**URL:** <https://discuss.elastic.co/t/exporting-dashboards-with-script/115844>\
**Category:** Kibana\
**Created:** [January 17, 2018, 7:52am UTC](https://discuss.elastic.co/t/exporting-dashboards-with-script/115844 "2018-01-17T07:52:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shubham\_Mahajan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shubham_mahajan/32/22140_2.png) [@Shubham\_Mahajan](https://discuss.elastic.co/u/Shubham_Mahajan)\
**Post date:** [January 17, 2018, 7:52am UTC](https://discuss.elastic.co/t/exporting-dashboards-with-script/115844/1 "2018-01-17T07:52:32Z")

</div>

Hi Team,  
I am trying to export dashboards, searches and visualizations to kibana using script.  
Now that mapping types is removed from indices, how can i push the saved objects.  
i am using this below `Curl` command:

> curl -s -XPUT '[http://localhost:9200/.kibana/doc/System\_Navigation](http://localhost:9200/.kibana/doc/System_Navigation)' -H "Content-Type: application/json" -d@/visualization/System\_Navigation.json

I am saving all the dashboards seperately as JSON files using export api in management tab from kibana. The format they are saved in is not the format that is being accepted while usin above command..it's giving errors for metadat fields `_id` `_type`

> "reason":"Field [\_id] is a metadata field and cannot be added inside a document. Use the index API request parameters."}

```
[
      {
        "_id": "0441cfb0-faa1-11e7-92ec-876f140dfe8f",
        "_type": "search",
        "_source": {
          "title": "Metricbeat Search",
          "description": "",
          "hits": 0,
          "columns": [
            "_source"
          ],
          "sort": [
            "@timestamp",
            "desc"
          ],
          "version": 1,
          "kibanaSavedObjectMeta": {
            "searchSourceJSON": "{\"index\":\"9d139a80-e696-11e7-8461-6326e2e461fd\",\"highlightAll\":true,\"version\":true,\"query\":{\"language\":\"lucene\",\"query\":\"\"},\"filter\":[]}"
          }
        }
      }
    ]

```

my question is how is it possible to export them..do i need to manually format all the exported JSONs (dashboard, visuals, searches and index patterns) like below to match the mapping of `.kibana` index like below:

```
{
          "type": "search",
          "updated_at": "2018-01-11T09:51:49.685Z",
          "search": {
            "title": "VMs search",
            "description": "",
            "hits": 0,
            "columns": [
              "_source"
            ],
            "sort": [
              "@timestamp",
              "desc"
            ],
            "version": 1,
            "kibanaSavedObjectMeta": {
              "searchSourceJSON": """{"index":"532c80a0-f5e9-11e7-8143-dbeab0fdfcdf","highlightAll":true,"version":true,"query":{"query":"","language":"lucene"},"filter":[{"meta":{"index":"532c80a0-f5e9-11e7-8143-dbeab0fdfcdf","negate":false,"disabled":false,"alias":null,"type":"exists","key":"resource_metadata.state","value":"exists"},"exists":{"field":"resource_metadata.state"},"$state":{"store":"appState"}}]}"""
            }
          }
        }

```

Please help!!

---

<div class="post-metadata">

**Author:** ![chrisronline](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrisronline/32/28230_2.png) [@chrisronline](https://discuss.elastic.co/u/chrisronline)\
**Post date:** [January 17, 2018, 2:44pm UTC](https://discuss.elastic.co/t/exporting-dashboards-with-script/115844/2 "2018-01-17T14:44:59Z")

</div>

Hi @Shubham_Mahajan,

You are correct.

The format used for import/export through the Saved Objects UI is different than when you're adding documents to an ES index.

The Saved Objects import process consumes raw ES documents, like:

```auto
{
    "_id": "PgSQL-transactions",
    "_type": "search",
    "_source": {
      "columns": [
        "method",
        "type",
        "path",
        "responsetime",
        "status"
      ],
      "description": "",
      "hits": 0,
      "kibanaSavedObjectMeta": {
        "searchSourceJSON": "{\"index\":\"packetbeat-*\",\"highlight\":{\"pre_tags\":[\"@kibana-highlighted-field@\"],\"post_tags\":[\"@/kibana-highlighted-field@\"],\"fields\":{\"*\":{}}},\"filter\":[{\"meta\":{\"index\":\"packetbeat-*\",\"negate\":false,\"key\":\"type\",\"value\":\"pgsql\",\"disabled\":false},\"query\":{\"match\":{\"type\":{\"query\":\"pgsql\",\"type\":\"phrase\"}}}}],\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}}}"
      },
      "sort": [
        "@timestamp",
        "desc"
      ],
      "title": "PgSQL transactions",
      "version": 1
    },
    "_meta": {
      "savedObjectVersion": 2
    }
  }

```

However, adding a document to a ES index just requires the source, which looks like:

```auto
{
  "type": "search",
  "search": {
    "columns": [
      "method",
      "type",
      "path",
      "responsetime",
      "status"
    ],
    "description": "",
    "hits": 0,
    "kibanaSavedObjectMeta": {
      "searchSourceJSON": "{\"index\":\"packetbeat-*\",\"highlight\":{\"pre_tags\":[\"@kibana-highlighted-field@\"],\"post_tags\":[\"@/kibana-highlighted-field@\"],\"fields\":{\"*\":{}}},\"filter\":[{\"meta\":{\"index\":\"packetbeat-*\",\"negate\":false,\"key\":\"type\",\"value\":\"pgsql\",\"disabled\":false},\"query\":{\"match\":{\"type\":{\"query\":\"pgsql\",\"type\":\"phrase\"}}}}],\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}}}"
    },
    "sort": [
      "@timestamp",
      "desc"
    ],
    "title": "PgSQL transactions",
    "version": 1
  }
}

```

For the latter, you specify the `id` as part of the URL, like: `http://localhost:9200/.kibana/doc/PgSQL-transactions`

Let me know if that helps!

Lemme know if that helps!

---

<div class="post-metadata">

**Author:** ![Shubham\_Mahajan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shubham_mahajan/32/22140_2.png) [@Shubham\_Mahajan](https://discuss.elastic.co/u/Shubham_Mahajan)\
**Post date:** [January 18, 2018, 6:18am UTC](https://discuss.elastic.co/t/exporting-dashboards-with-script/115844/3 "2018-01-18T06:18:20Z")

</div>

@chrisronline So basically i'm gonna have to manually modify each JSON object to the required format and post it..right??  
Also if i push the dashboards and visualizations, they use specific ID's () to identify searches and dashboard so i'm gonna have to use that id for posting these objects right??

---

<div class="post-metadata">

**Author:** ![chrisronline](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrisronline/32/28230_2.png) [@chrisronline](https://discuss.elastic.co/u/chrisronline)\
**Post date:** [January 18, 2018, 2:11pm UTC](https://discuss.elastic.co/t/exporting-dashboards-with-script/115844/4 "2018-01-18T14:11:06Z")

</div>

Yes, that sounds right @Shubham_Mahajan.

If you're exporting Saved Objects using the UI, you could just import them through the UI too and you wouldn't have to modify the json.

However, if you're manually exporting and then programmatically importing, you will need to modify the source.

---

<div class="post-metadata">

**Author:** ![Shubham\_Mahajan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shubham_mahajan/32/22140_2.png) [@Shubham\_Mahajan](https://discuss.elastic.co/u/Shubham_Mahajan)\
**Post date:** [January 18, 2018, 2:24pm UTC](https://discuss.elastic.co/t/exporting-dashboards-with-script/115844/5 "2018-01-18T14:24:01Z")

</div>

Oh man it’s gonna be a lot of work😅.. Thanks a lot for the info, Chris!!

---

<div class="post-metadata">

**Author:** ![chrisronline](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chrisronline/32/28230_2.png) [@chrisronline](https://discuss.elastic.co/u/chrisronline)\
**Post date:** [January 18, 2018, 2:45pm UTC](https://discuss.elastic.co/t/exporting-dashboards-with-script/115844/6 "2018-01-18T14:45:24Z")

</div>

Good luck!

---

<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:** [February 15, 2018, 2:45pm UTC](https://discuss.elastic.co/t/exporting-dashboards-with-script/115844/7 "2018-02-15T14:45:28Z")

</div>

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