elasticsearch Index lifecycle policiesの使い方

Index lifecycle policiesとは

名前の通り、indexのライフサイクルを管理する機能です。 これまで外部からしかできなかったindexのライフサイクルの管理を設定できるようになりました。

https://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-management.html

設定の流れ

  1. kibanaのIndex lifecycle policiesからルールを管理する
  2. templateに設定する
  3. 既存のindexに設定する

詳細

画面

f:id:ryook:20190925001345p:plain

ルール設定

  • days form index creationなので、保持日数+1にしておきます

f:id:ryook:20190925001448p:plain

templateに設定

  • ここからtempalteに設定します
  • 設定したルールは次に作成される’indexから適応されます

f:id:ryook:20190925001523p:plain

既存indexに設定

  • 既存のindexにはこの画面からは設定できない&template更新しても既存のindexは変更されないので、APIで直接settingsを変更しましょう
PUT log-*/_settings
{
  "lifecycle" : {
      "name" : "DELETE-60days-ago"
    }
}