Migrating Kibana index to 6.0

edit

Migrating Kibana index to 6.0

edit

The following will make transformations to your Kibana index. It is recommended you backup your Kibana index prior to running any of the following commands.

In order to migrate to Kibana 6, your Kibana index needs to be reindexed. This will make transformations to the data model, removing types which are being removed in Elasticsearch.

A UI is available in X-Pack 5.6 to assist with the migration. The following is provided should you be required to run the migration manually. The commands assume you’re using the default .kibana index, without an alias. If kibana.index is set to something different in your kibana.yml, or you’re using an alias, you will need to modify the commands.

To perform this migration without downtime, you will need to be running Kibana 5.6. This is the only version which supports both of the index types. When running 5.6, add "index.format": 6 and "index.mapping.single_type": true under settings in the second step to ensure additional types will not be added after migrating.

  1. Set .kibana index to read-only:

    PUT .kibana/_settings
    {
      "index.blocks.write": true
    }
  2. Create .kibana-6 index

    PUT .kibana-6
    {
      "settings" : {
        "number_of_shards" : 1,
        "index.mapper.dynamic": false
      },
      "mappings" : {
        "doc": {
          "properties": {
            "type": {
              "type": "keyword"
            },
            "updated_at": {
              "type": "date"
            },
            "config": {
              "properties": {
                "buildNum": {
                  "type": "keyword"
                }
              }
            },
            "index-pattern": {
              "properties": {
                "fieldFormatMap": {
                  "type": "text"
                },
                "fields": {
                  "type": "text"
                },
                "intervalName": {
                  "type": "keyword"
                },
                "notExpandable": {
                  "type": "boolean"
                },
                "sourceFilters": {
                  "type": "text"
                },
                "timeFieldName": {
                  "type": "keyword"
                },
                "title": {
                  "type": "text"
                }
              }
            },
            "visualization": {
              "properties": {
                "description": {
                  "type": "text"
                },
                "kibanaSavedObjectMeta": {
                  "properties": {
                    "searchSourceJSON": {
                      "type": "text"
                    }
                  }
                },
                "savedSearchId": {
                  "type": "keyword"
                },
                "title": {
                  "type": "text"
                },
                "uiStateJSON": {
                  "type": "text"
                },
                "version": {
                  "type": "integer"
                },
                "visState": {
                  "type": "text"
                }
              }
            },
            "search": {
              "properties": {
                "columns": {
                  "type": "keyword"
                },
                "description": {
                  "type": "text"
                },
                "hits": {
                  "type": "integer"
                },
                "kibanaSavedObjectMeta": {
                  "properties": {
                    "searchSourceJSON": {
                      "type": "text"
                    }
                  }
                },
                "sort": {
                  "type": "keyword"
                },
                "title": {
                  "type": "text"
                },
                "version": {
                  "type": "integer"
                }
              }
            },
            "dashboard": {
              "properties": {
                "description": {
                  "type": "text"
                },
                "hits": {
                  "type": "integer"
                },
                "kibanaSavedObjectMeta": {
                  "properties": {
                    "searchSourceJSON": {
                      "type": "text"
                    }
                  }
                },
                "optionsJSON": {
                  "type": "text"
                },
                "panelsJSON": {
                  "type": "text"
                },
                "refreshInterval": {
                  "properties": {
                    "display": {
                      "type": "keyword"
                    },
                    "pause": {
                      "type": "boolean"
                    },
                    "section": {
                      "type": "integer"
                    },
                    "value": {
                      "type": "integer"
                    }
                  }
                },
                "timeFrom": {
                  "type": "keyword"
                },
                "timeRestore": {
                  "type": "boolean"
                },
                "timeTo": {
                  "type": "keyword"
                },
                "title": {
                  "type": "text"
                },
                "uiStateJSON": {
                  "type": "text"
                },
                "version": {
                  "type": "integer"
                }
              }
            },
            "url": {
              "properties": {
                "accessCount": {
                  "type": "long"
                },
                "accessDate": {
                  "type": "date"
                },
                "createDate": {
                  "type": "date"
                },
                "url": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 2048
                    }
                  }
                }
              }
            },
            "server": {
              "properties": {
                "uuid": {
                  "type": "keyword"
                }
              }
            },
            "timelion-sheet": {
              "properties": {
                "description": {
                  "type": "text"
                },
                "hits": {
                  "type": "integer"
                },
                "kibanaSavedObjectMeta": {
                  "properties": {
                    "searchSourceJSON": {
                      "type": "text"
                    }
                  }
                },
                "timelion_chart_height": {
                  "type": "integer"
                },
                "timelion_columns": {
                  "type": "integer"
                },
                "timelion_interval": {
                  "type": "keyword"
                },
                "timelion_other_interval": {
                  "type": "keyword"
                },
                "timelion_rows": {
                  "type": "integer"
                },
                "timelion_sheet": {
                  "type": "text"
                },
                "title": {
                  "type": "text"
                },
                "version": {
                  "type": "integer"
                }
              }
            },
            "graph-workspace": {
              "properties": {
                "description": {
                  "type": "text"
                },
                "kibanaSavedObjectMeta": {
                  "properties": {
                    "searchSourceJSON": {
                      "type": "text"
                    }
                  }
                },
                "numLinks": {
                  "type": "integer"
                },
                "numVertices": {
                  "type": "integer"
                },
                "title": {
                  "type": "text"
                },
                "version": {
                  "type": "integer"
                },
                "wsState": {
                  "type": "text"
                }
              }
            }
          }
        }
      }
    }
  3. Reindex .kibana into .kibana-6:

    POST _reindex
    {
      "source": {
        "index": ".kibana"
      },
      "dest": {
        "index": ".kibana-6"
      },
      "script": {
        "inline": "ctx._source = [ ctx._type : ctx._source ]; ctx._source.type = ctx._type; ctx._id = ctx._type + \":\" + ctx._id; ctx._type = \"doc\"; ",
        "lang": "painless"
      }
    }
  4. Alias .kibana-6 to .kibana and remove legacy .kibana index:

    POST /_aliases
    {
      "actions" : [
        { "add":  { "index": ".kibana-6", "alias": ".kibana" } },
        { "remove_index": { "index": ".kibana" } }
      ]
    }