Help us understand the problem. What is going on with this article?

KibanaのVisualizeで利用しているIndex Patternsをまとめて変更する

More than 1 year has passed since last update.

Elasticsearchのインデックス名変更に伴い、KibanaのVisualizeで利用しているIndex Patternsを変更するというあんまり発生しない作業の必要があったのでメモ。

環境

  • Elasticsearch 6.1.1
  • Kibana 6.1.1

test-hoge-foodsというindexがあり、test-hoge*でIndex Patternsを登録しています。
中身は以下のような感じで種類と名前と個数が適当に登録されています。

{
    "_index": "test-hoge-foods",
        "_type": "food",
        "_id": "1",
        "_score": 1,
        "_source": {
          "type": "野菜",
          "name": "にんじん",
          "count": 3
}

また、Visualizeを2つ作成し、以下のようなダッシュボードを作成しています。
変更前のダッシュボード

手順

例としてtest-hoge-foodsをtest-piyo-foodsへ変えてみます。

1. test-hoge-foodsをtest-piyo-foodsへReindex

ついでにtest-hoge-foodsはcloseしておきます(削除でも可)

POST _reindex
{
  "source": {
    "index": "test-hoge-foods"
  },
  "dest": {
    "index": "test-piyo-foods"
  }
}
POST /test-hoge-foods/_close

2. test-piyo-foods用のIndex Patternsを登録

新しいIndex Patternsの登録

3. Index Patternsを変更したいVisualizeをExport

Saved Objectsから設定を変更したいVisualizeを出力します。
(ダッシュボードはVisualizeのidを利用しており、直接Index Patternsを指定しているわけではないので変更不要です)

4. 出力したjsonを編集

searchSourceJSONのindexをtest-piyo-foodsのIndex Patternsのidへ変更します。
export.jsonの変更箇所

Index Patternsのidは.kibanaのインデックスから確認できます。

GET .kibana/_search
{
  "query":{
    "match": {
      "type": "index-pattern"
    }
  }
}

_idが"index-pattern:xxxxx"となっており、xxxxxの部分がIndex Patternsのidになります。

5. 編集したjsonをImport

編集したjsonをSaved Objectsから取り込みます。

これで移行完了です。(必要なら古い方のIndex Patternsは削除してください)
変更後のダッシュボード

ちなみに

indexにAliasの設定をしていればKibana側の移行はしなくても済んだと思います。。。

NAO_MK2
Web業界で生きてるエンジニア
retty
Retty株式会社はソーシャルメディア、スマートフォンを活かした「人を軸にお店を探せる」グルメサービスRettyを運営する会社です。
https://retty.me
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした