Skip to content
Snippets Groups Projects
Commit 7e7089d4 authored by jurgenhaas's avatar jurgenhaas
Browse files

Add support for aliases to purge script

parent 630728d7
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,17 @@ def getIndex():
return json.loads(buffer.getvalue())
def getAliases():
buffer = BytesIO()
c = pycurl.Curl()
c.setopt(c.URL, 'http://%s:%s@localhost:9200/_cat/aliases?v&pretty&s=index&format=json' % (args.username, args.password))
c.setopt(c.HTTPHEADER, ['Content-Type: application/json'])
c.setopt(c.WRITEDATA, buffer)
c.perform()
c.close()
return json.loads(buffer.getvalue())
def purgeSingle(cat, day):
for index in cat:
if index['index'] == args.index:
......@@ -86,6 +97,10 @@ def purgeDaily(cat, day):
cat = getIndex()
for alias in getAliases():
if alias['alias'] == args.index:
args.index = alias['index']
break
day = date.today() + relativedelta(days=-int(args.retention))
print('Purge index %s older than %s' % (args.index, day))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment