Home > Mobile >  How to access Gitlab's metrics (Prometheus and Grafana) from Docker installation?
How to access Gitlab's metrics (Prometheus and Grafana) from Docker installation?

Time:10-26

I installed Gitlab using Docker image on a Ubuntu virtual machine running on a MAC M1 as follows (https://hub.docker.com/r/yrzr/gitlab-ce-arm64v8):

docker run \
  --detach \
  --restart always \
  --name gitlab-ce \
  --privileged \
  --memory 4096M \
  --publish 22:22 \
  --publish 80:80 \
  --publish 443:443 \
  --hostname 127.0.0.1 \
  --env GITLAB_OMNIBUS_CONFIG=" \
    nginx['redirect_http_to_https'] = true; "\
  --volume /srv/gitlab-ce/conf:/etc/gitlab:z \
  --volume /srv/gitlab-ce/logs:/var/log/gitlab:z \
  --volume /srv/gitlab-ce/data:/var/opt/gitlab:z \
  yrzr/gitlab-ce-arm64v8:latest

All seems to be working correctly on localhost, except that I can't access the metrics, I got unable to connect error on:

Prometheus: http://localhost:9090
Grafana: http://localhost/-/grafana

I tried enabling metrics as in the documentation, and docker exec -it gitlab-ce gitlab-ctl reconfigure

What I'm missing?
Thanks

CodePudding user response:

When Gitlab uses localhost this will resolve the localhost on the container and not the host (so your Mac).

There are two options to solve this:

  1. Use host.docker.internal instead of localhost (this resolves to the internal IP address used by the host) - see this doc for more info
  2. Configure your container to use the host network by adding this to the docker run command: --network=host which will let your container and host to share the same network stack (however, this is not supported nu Docker Desktop for mac according to this)
  • Related