Menghapus Elasticsearch Indices dengan Curator Bag (2)
Dulu pernah menggunakan curator_cli untuk menghapus indices. Namun config yang lama tidak bisa digunakan untuk ES 5.2.x. Mari kita coba cara baru ini (ndak baru-baru amat sih).
- Install curator (via pip)
$ pip install elasticsearch-curator
- Perintah dasar curator adalah:
$ curator [--config CONFIG.YML] [--dry-run] ACTION_FILE.YML
- Atur configurasi dalam file config.yml
$ cd ~ $ vim config.yml
Isinya kira-kira begini:
--- # Remember, leave a key empty if there is no value. None will be a string, # not a Python "NoneType" client: hosts: - 192.168.33.201 #ip publish es port: 9200 url_prefix: use_ssl: False certificate: client_cert: client_key: ssl_no_validate: False http_auth: timeout: 30 master_only: False logging: loglevel: INFO logfile: logformat: default blacklist: ['elasticsearch', 'urllib3']
- Atur aksi yang akan dilakukan dalam file delete_indices.yml
$ vim delete_indices.yml
Isinya kira-kira begini:
--- # Remember, leave a key empty if there is no value. None will be a string, # not a Python "NoneType" # # Also remember that all examples have 'disable_action' set to True. If you # want to use this action as a template, be sure to set this to False after # copying it. actions: 1: action: delete_indices description: >- Delete indices older than 7 days (based on index name), #for filebeat- prefixed indices. Ignore the error if the filter does not result in an actionable list of indices (ignore_empty_list) and exit cleanly. options: ignore_empty_list: True disable_action: False filters: #- filtertype: pattern # kind: prefix # value: filebeat- - filtertype: age source: name direction: older timestring: '%Y.%m.%d' unit: days unit_count: 7
- Testing konfigurasi curator.
$ curator --config config.yml delete_indices.yml
- Atur penjadwalan curator dalam crontab
$ crontab -e
Isi cron kira-kira begini:
0 6 * * * /usr/local/bin/curator --config /home/user/config.yml /home/user/delete_indices.yml
Selesai.
Bacaan:
[0] https://www.elastic.co/guide/en/elasticsearch/client/curator/current/command-line.html
Estu~
Advertisements
Reply