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