Skip to content

Commit

Permalink
Merge pull request #2 from Braedon/1-config-file-logging
Browse files Browse the repository at this point in the history
Issue 1 - improve logging around missing/empty config files
  • Loading branch information
braedon authored Jul 21, 2016
2 parents 0960a33 + 12494ff commit bcb9523
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions prometheus_es_exporter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def main():
es_cluster = args.es_cluster.split(',')

config = configparser.ConfigParser()
config.read(args.config_file)
config.read_file(open(args.config_file))

query_prefix = 'query_'
queries = {}
Expand All @@ -119,20 +119,24 @@ def main():

queries[query_name] = (query_interval, query_indices, query)

es_client = Elasticsearch(es_cluster)
if queries:
es_client = Elasticsearch(es_cluster)

scheduler = sched.scheduler()
scheduler = sched.scheduler()

logging.info('Starting server...')
start_http_server(port)
logging.info('Server started on port %s', port)
logging.info('Starting server...')
start_http_server(port)
logging.info('Server started on port %s', port)

for name, (interval, indices, query) in queries.items():
run_scheduler(scheduler, es_client, name, interval, indices, query)
for name, (interval, indices, query) in queries.items():
run_scheduler(scheduler, es_client, name, interval, indices, query)

try:
scheduler.run()
except KeyboardInterrupt:
pass
try:
scheduler.run()
except KeyboardInterrupt:
pass

else:
logging.warn('No queries found in config file %s', args.config_file)

logging.info('Shutting down')

0 comments on commit bcb9523

Please sign in to comment.