Skip to content

Commit

Permalink
Fix PROMETHEUS_CONTAINER_PORT for Python3
Browse files Browse the repository at this point in the history
  • Loading branch information
krcz committed Mar 30, 2020
1 parent ece6ca2 commit 7d2c047
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions discoverecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,12 @@ def task_info_to_targets(task_info):
else:
first_port = '80'
elif prom_container_port:
binding_by_container_port = filter(lambda c:str(c['containerPort']) == prom_container_port, container['networkBindings'])
first_port = str(binding_by_container_port[0]['hostPort'])
binding_by_container_port = [c for c in container['networkBindings'] if str(c['containerPort']) == prom_container_port]
if binding_by_container_port:
first_port = str(binding_by_container_port[0]['hostPort'])
else:
log(task_info.task['group'] + ':' + container_definition['name'] + ' does not expose port matching PROMETHEUS_CONTAINER_PORT, omitting')
return []
else:
first_port = str(container['networkBindings'][0]['hostPort'])

Expand Down

0 comments on commit 7d2c047

Please sign in to comment.