Using dockerswarm_sd_configs with HTTP and custom port and path

355 views
Skip to first unread message

James Mills

unread,
Apr 8, 2021, 3:11:47 AM4/8/21
to Prometheus Users
Hello all,

From the docs (https://prometheus.io/docs/guides/dockerswarm/) you can easily use the Docker UNIX Socket like so:

  - job_name: 'docker'
    dockerswarm_sd_configs:
      - host: unix:///var/run/docker.sock

However I'm struggling to work with a Docker API that is exposed over HTTP with a custom port and path. For example:

  - job_name: 'docker'
    dockerswarm_sd_configs:

This doesn't work and results in a dns resolution failure.

I've also tried relabel_configs like:

  - job_name: 'docker'
    dockerswarm_sd_configs:
      - host: http://docker_proxy
        role: nodes
    relabel_configs:
      - source_labels: [__address__]
        regex: ".*"
        target_label: __address__
        replacement: $1:8000/proxy

But this doesn't work either, the error suggests that the port isn'g being used to connect to the Docker API at all, nor the path.

I must be doing something wrong, or using a custom port + path isn't supproted?

The reason btw I'm doing this is because the upstream prom/prometheus image (rightfully so) now runs as the "nobody" user making it quite difficult to bind-mount the Docker UNIX socket in a consistent way. So running a proxy that re-exposes it over HTTP and drops privileges seems to be the best approach here.

Kind regards

James

Reply all
Reply to author
Forward
0 new messages