LoginSignup
2
0

More than 5 years have passed since last update.

ElasticSearch(v2)でCuratorを使う

Last updated at Posted at 2016-12-23

indexの内容を消したい時

curatorとは、Elastic searchのindexの操作やスナップショットを管理できる機能を持っています。
運用していてそろそろこれを動かそうと思ったらv4以前とv4ではコマンドが変わっていてそのままだと動きません。WEB上にもv4系の情報は少なめ。

今まではこういう設定をしていたかと思います。

curator --host 127.0.0.1 close indices --prefix logstash --older-than  7 --time-unit days --timestring %Y.%m.%d

2016.12.23現在の最新はv4.2
pip/apt/yum/zip/msiでインストールできます。

コマンドラインリファレンス

pip install elasticsearch-curator

ymlファイルで管理できるようになっていた。

こんな感じで書く

actions:
  1:
    action: close
    description: Close indices older than 30 days (based on index name), for logstash
    options:
      delete_aliases: False
      timeout_override:
      continue_if_exception: False
      disable_action: True
    filters:
    - filtertype: pattern
      kind: prefix
      value: logstash-
      exclude:
    - filtertype: age
      source: name
      direction: older
      timestring: '%Y.%m.%d'
      unit: days
      unit_count: 30 #何日前
      exclude:

今までコマンドでやっていたからコマンドでやりたい

こんな風に設定しています

細かく設定したい時はymlで設定する方が良いかも。

/$PATH/curator_cli --config /path/to/curator.yml

または、cronなどにはこのように設定している。

/$PATH/curator_cli --host 127.0.0.1 delete_indices --filter_list '[{"filtertype":"age","source":"creation_date","direction":"older","unit":"days","unit_count":120},{"filtertype":"pattern","kind":"prefix","value":"logstash"}]' >/dev/null 2>&1
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0