如果使用elasticsearch时,你是使用时间作为索引,那么可以通过curator对索引进行管理。通过curator可以大大简化索引的管理成本。
github: https://github.com/elasticsearch/curator
缺省的选项:
--host localhost
--port 9200
-t (or --timeout) 30
-T (or --time-unit) days
-p (or --prefix) logstash-
curator匹配索引的方式是:prefix + 时间字符串格式 + suffix
其中时间字符串格式可以通过使用python strftime formatting构造。
使用方法:
1. 删除30天前的索引
curator delete --older-than 30
2. 关闭14天前的所有索引
curator close --older-than 14
3. 列出所有索引
curator show --show-indices