ElasticSearch Curator
Curator 一個用來管理 ElasticSearch indices/snapshots 的工具
之前有用這個來刪除 indices,但是因為之前用的指令比較簡單,都是統一刪除 21 天前的資料
現在裡面資料比較複雜,所以需要做一些變化
原本以為是不是下兩次指令就好,現在發現可以一次指定多個設定一次做~
CONFIG
連接 ElasticSearch 所需要的設定檔案,預設是應該放在 ~/.curator/curator.yml
1 | client: |
2 | hosts: |
3 | - es |
4 | port: 9200 |
5 | url_prefix: |
6 | use_ssl: False |
7 | certificate: |
8 | client_cert: |
9 | client_key: |
10 | ssl_no_validate: False |
11 | http_auth: |
12 | timeout: 30 |
13 | master_only: False |
14 | |
15 | logging: |
16 | loglevel: INFO |
17 | logfile: |
18 | logformat: default |
19 | blacklist: ['elasticsearch', 'urllib3'] |
Action
我這邊因為會有兩組 indices
其中我想 topbeat 資料比較多,保留七天。
packetbeat 資料比較少,可以保留久一點,所以我就分兩個 action 來設定
1 | actions: |
2 | 1: |
3 | action: delete_indices |
4 | description: remove topbeat indices |
5 | options: |
6 | ignore_empty_list: True |
7 | timeout_override: |
8 | continue_if_exception: False |
9 | disable_action: |
10 | filters: |
11 | - filtertype: pattern |
12 | kind: prefix |
13 | value: topbeat- |
14 | exclude: |
15 | - filtertype: age |
16 | source: name |
17 | direction: older |
18 | timestring: '%Y.%m.%d' |
19 | unit: days |
20 | unit_count: 7 |
21 | exclude: |
22 | 2: |
23 | action: delete_indices |
24 | description: remove packetbeat indices |
25 | options: |
26 | ignore_empty_list: True |
27 | timeout_override: |
28 | continue_if_exception: False |
29 | disable_action: |
30 | filters: |
31 | - filtertype: pattern |
32 | kind: prefix |
33 | value: packetbeat- |
34 | exclude: |
35 | - filtertype: age |
36 | source: name |
37 | direction: older |
38 | timestring: '%Y.%m.%d' |
39 | unit: days |
40 | unit_count: 35 |
41 | exclude: |
執行
接下來只需要執行下面指令就可以了~
1 | > curator action.yml |
Docker
我把專案放在 Github 上面: elasticsearch-curator