---
# System prepended metadata

title: Kibana migration
tags: [Kibana]

---

---
title: Kibana migration
tags: Kibana
description: View the slide with "Slide Mode".
---

# Kibana migration

## [<font color=blue>Export objects API</font>](https://www.elastic.co/guide/en/kibana/7.x/saved-objects-api-export.html)

#### 指令
```htmlmixed=
curl -X POST "localhost:5601/api/saved_objects/_export" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d'
{
  "type": "dashboard"
}
'
```
#### 結果
```jsonld=
{
   "attributes":{
      "description":"",
      "hits":0,
      "kibanaSavedObjectMeta":{
         "searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}"
      },
      "optionsJSON":"{\"useMargins\":true,\"hidePanelTitles\":false}",
      "panelsJSON":"[{\"gridData\":{\"w\":24,\"h\":15,\"x\":0,\"y\":0,\"i\":\"1\"},\"version\":\"7.3.2\",\"panelIndex\":\"1\",\"embeddableConfig\":{},\"panelRefName\":\"panel_0\"},{\"gridData\":{\"w\":24,\"h\":15,\"x\":24,\"y\":0,\"i\":\"2\"},\"version\":\"7.3.2\",\"panelIndex\":\"2\",\"embeddableConfig\":{},\"panelRefName\":\"panel_1\"},{\"gridData\":{\"w\":24,\"h\":15,\"x\":0,\"y\":15,\"i\":\"3\"},\"version\":\"7.3.2\",\"panelIndex\":\"3\",\"embeddableConfig\":{},\"panelRefName\":\"panel_2\"}]",
      "timeRestore":false,
      "title":"[es-test]New Dashboard2",
      "version":1
   },
   "id":"54e5a620-77af-11ea-ab37-0d506aa29a78",
   "migrationVersion":{
      "dashboard":"7.3.0"
   },
   "references":[
      {
         "id":"8e1567c0-77a8-11ea-ab37-0d506aa29a78",
         "name":"panel_0",
         "type":"visualization"
      },
      {
         "id":"587bf070-77a8-11ea-ab37-0d506aa29a78",
         "name":"panel_1",
         "type":"search"
      },
      {
         "id":"8e1567c0-77a8-11ea-ab37-0d506aa29a78",
         "name":"panel_2",
         "type":"visualization"
      }
   ],
   "type":"dashboard",
   "updated_at":"2020-04-06T02:35:51.554Z",
   "version":"WzE1LDFd"
}
```
### [type](https://www.elastic.co/guide/en/kibana/7.x/saved-objects-api-get.html)
1. visualization
1. dashboard
1. search
1. index-pattern
1. config
1. timelion-sheet

### [Import objects API](https://www.elastic.co/guide/en/kibana/7.x/saved-objects-api-import.html)
>[name=昱齊]順序很重要！要先有index-pattern -> search -> visualzation -> dashboard

---
>[name=昱齊] space/tenancy/tenants呢
>[name=昱齊] tenant[啟動](https://opendistro.github.io/for-elasticsearch-docs/docs/security-access-control/multi-tenancy/)
>[name=昱齊] open distro的tenant目前有bug, [tenant migration index  - issue 102](https://github.com/opendistro-for-elasticsearch/security-kibana-plugin/issues/102)

### index `.kibana_1`存什麼
- 升版時才會用到，Saved object migrations
- 系統會自動處理不同版本object的問題
> <font color=blue>Saved objects are stored</font> in an index named .kibana_N, where N is a number that increments over time as Kibana is upgraded. The index alias <font color=blue>.kibana</font> points to the latest up-to-date index for a given install.
[官方文件](https://www.elastic.co/guide/en/kibana/7.3/upgrade-migrations.html)
>[name=昱齊] 所以直接搬移index即可全部物件轉移嗎？

### 盤點資料
1. Discoveries
1. dashboards
1. visualizations
1. index patterns
1. user space

---
## 網頁操作
1. #### "FROM"-instance:
```
Settings -> Objects -> Export all Discoveries
Settings -> Objects -> Export all Visualizations
Settings -> Objects -> Export all Dashboards
```
2. #### "TO"-instance:
```
Settings -> Objects -> Import all Discoveries
Settings -> Objects -> Import all Visualizations
Settings -> Objects -> Import all Dashboards
```

## <font color=#F0B5A5>指令操作</font>
```
# export
$ curl -u elastic:changeme http://localhost:5601/s/marketing/api/kibana/dashboards/export?dashboard=d203dd90-deac-11e8-869e-d73106bbd5ad > export.json

# import
$ curl -H "Content-Type: application/json" -H "kbn-xsrf: true" -u elastic:changeme http://localhost:5601/s/sales/api/kibana/dashboards/import --data-binary @export.json
```
[出處](https://www.elastic.co/blog/how-to-migrate-to-kibana-spaces)

