Skip to content

Fix Prometheus listen on separate port in Docker

Catalin Irimie requested to merge cat-fix-prometheus-separate-port into main

What does this Merge Request do and why?

Previous to this, we were mapping the same changed port in the container to the host, while the Prometheus service is listening to the default 9090 port inside the container.

With config.prometheus.port set to 19090, example below.

Before:

╰─>$ curl gdk.test:19090
curl: (7) Failed to connect to gdk.test port 19090 after 0 ms: Connection refused

╰─>$ docker ps
CONTAINER ID   IMAGE                     COMMAND                  CREATED              STATUS              PORTS                                                     NAMES
51bcea809782   prom/prometheus:v2.25.0   "/bin/prometheus --c…"   About a minute ago   Up About a minute   9090/tcp, 0.0.0.0:19090->19090/tcp, :::19090->19090/tcp   hardcore_bhaskara

╰─>$ docker exec -it 51bcea sh
/prometheus $ netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 :::9090                 :::*                    LISTEN      1/prometheus

After:

╰─>$ docker ps
CONTAINER ID   IMAGE                     COMMAND                  CREATED         STATUS         PORTS                                         NAMES
ca68b72b12bd   prom/prometheus:v2.25.0   "/bin/prometheus --c…"   3 seconds ago   Up 2 seconds   0.0.0.0:19090->9090/tcp, :::19090->9090/tcp   pedantic_saha

╰─>$ curl gdk.test:19090
<a href="/graph">Found</a>.

Merge Request checklist

  • This change is backward compatible. If not, please include steps to communicate to our users.
  • Tests added for new functionality. If not, please raise Issue to follow-up.
  • Documentation added/updated, if needed.
  • gdk doctor test added, if needed.
  • Add the ~highlight label if this MR should be included in the CHANGELOG.md.

Merge request reports

Loading