Skip to content

Commit

Permalink
Merge pull request #8 from krcz/prometheus-container-port
Browse files Browse the repository at this point in the history
Fix PROMETHEUS_CONTAINER_PORT for Python3
  • Loading branch information
fredsig authored May 17, 2020
2 parents ece6ca2 + 7d2c047 commit b543bc0
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 b543bc0

Please sign in to comment.