安裝 curator
pip install elasticsearch-curator改目標 改天數
#!/usr/bin/env python # -*- coding: utf-8 -*- from elasticsearch import Elasticsearch import curator # 設定es位置 es = Elasticsearch('https://vpc-log-uri.us-west-2.es.amazonaws.com') index_list = curator.IndexList(es) # 設定搜尋的前綴字 index_list.filter_by_regex(kind='prefix', value='logstash-production-*') # 設定幾天之前 這邊14天 index_list.filter_by_age(source='name', direction='older', timestring='%Y.%m.%d', unit='days', unit_count=14) # delete selected indices curator.DeleteIndices(index_list).do_action() for index in index_list.working_list(): print 'Delete: ' + index
留言
張貼留言