Returning wrong port if multiple ports are exposed
mthenw opened this issue · comments
If there is a service that exposes multiple ports, sometimes wrong port is returned. The issue is that NetworkBindings are sometimes returned in a different order than the ports defined in task definition.
https://github.com/teralytics/prometheus-ecs-discovery/blob/master/main.go#L184
It means that extracting exposed port based on the index in the returned array is not reliable. The solution for that is to use port number instead of port index:
PROMETHEUS_EXPORTER_PORT=4000
assuming that 4000 is a port exposed by the container.
hey @mthenw,
Solved this issue just as you described :-), please see the referenced PR
Makes total sense. Thanks for that!
PR is merged, closing the issue.