9 logger = logging.getLogger('clear_kibana')
10 logger.setLevel(logging.DEBUG)
11 file_handler = logging.FileHandler('/var/log/{}.log'.format('clear_kibana'))
12 file_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s'))
13 logger.addHandler(file_handler)
16 def delete_all(url, es_creds):
17 ids = shared_utils.get_elastic_docs(url, es_creds, body=None, field='_id')
19 del_url = '/'.join([url, id])
20 shared_utils.delete_request(del_url, es_creds)
23 if __name__ == '__main__':
24 parser = argparse.ArgumentParser(description='Delete saved kibana searches, visualizations and dashboards')
25 parser.add_argument('-e', '--elasticsearch-url', default='http://localhost:9200',
26 help='the url of elasticsearch, defaults to http://localhost:9200')
28 parser.add_argument('-u', '--elasticsearch-username', default=None,
29 help='The username with password for elasticsearch in format username:password')
31 args = parser.parse_args()
32 base_elastic_url = args.elasticsearch_url
33 es_creds = args.elasticsearch_username
35 urls = (urlparse.urljoin(base_elastic_url, '/.kibana/visualization'),
36 urlparse.urljoin(base_elastic_url, '/.kibana/dashboard'),
37 urlparse.urljoin(base_elastic_url, '/.kibana/search'))
40 delete_all(url, es_creds)