templates icon indicating copy to clipboard operation
templates copied to clipboard

swarm monitoring use node and internal ips for identiy

Open devMls opened this issue 1 year ago • 2 comments

Imn hte grafana dashboards for swarm monitoring

This show:

image

is possible change to use node name or NODE ip?

devMls avatar Nov 04 '24 23:11 devMls

Hello,

I have the same issue. maybe there is some tags available into the database ?

hugodeprez avatar Jun 27 '25 07:06 hugodeprez

it takes me lot of hours to understand how prometheus works and how docker swarm create labels but here is working prometheus.yml config for this.

  • ensure we have access to swarm registry through socket, provide a volume to : - "/var/run/docker.sock:/var/run/docker.sock:ro"

  • add ruser root to be able to read sock file user: root # to be able to read docker.sock

finally prometheus.yml file to provide with a volume :

  - job_name: 'node-exporter'
    dockerswarm_sd_configs:
      - host: "unix:///var/run/docker.sock"
        refresh_interval: 30s
        role: tasks

    relabel_configs:
      # filter node-exporter containers
      - source_labels: [__meta_dockerswarm_service_name]
        regex: .*node-exporter.*
        action: keep

      # only keep active tasks
      - source_labels: [__meta_dockerswarm_task_state]
        regex: running
        action: keep

      # change port 80 to 9100
      - source_labels: [__address__]
        regex: '([^:]+):\d+'
        replacement: '${1}:9100'
        target_label: '__address__'

      # set physical hostname into instance label
      - source_labels: [__meta_dockerswarm_node_hostname]
        target_label: instance

will try to propose a PR for this. Hope this helps

hdep avatar Aug 29 '25 16:08 hdep