Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import requests
- logstash_url = 'http://localhost:9200'
- indices_limit = 7
- response = requests.get('%s/_stats' % logstash_url)
- data = response.json()
- def get_logstash_indices(data):
- return [indice for indice in sorted(data['indices']) if indice.startswith('logstash')]
- logstash_indices = get_logstash_indices(data)
- for indice in logstash_indices[:-indices_limit]:
- print "deleting indice %s" % indice
- requests.delete('%s/%s' % (logstash_url, indice))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement