Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import requests
  4.  
  5. logstash_url = 'http://localhost:9200'
  6. indices_limit = 7
  7.  
  8. response = requests.get('%s/_stats' % logstash_url)
  9. data = response.json()
  10.  
  11. def get_logstash_indices(data):
  12.     return [indice for indice in sorted(data['indices']) if indice.startswith('logstash')]
  13.  
  14. logstash_indices = get_logstash_indices(data)
  15.  
  16. for indice in logstash_indices[:-indices_limit]:
  17.     print "deleting indice %s" % indice
  18.     requests.delete('%s/%s' % (logstash_url, indice))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement