# Docker swarm node exporter host name

**URL:** https://discuss.prometheus.io/t/docker-swarm-node-exporter-host-name/3459
**Category:** General Help/Support
**Created:** [August 28, 2025, 12:13pm UTC](https://discuss.prometheus.io/t/docker-swarm-node-exporter-host-name/3459 "2025-08-28T12:13:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![romgo](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@romgo](https://discuss.prometheus.io/u/romgo)
#### Post date: [August 28, 2025, 12:13pm UTC](https://discuss.prometheus.io/t/docker-swarm-node-exporter-host-name/3459/1 "2025-08-28T12:13:11Z")

</div>

hello,

I deployed node exporter on all my docker Hosts on a docker swarm cluster. My central prometheus is able through the swarm inventory to pull data from all node exporter containers.

The issue I have on prometheus is the instance is not the name of the host, but the IP of the node exporter container. This is a big issue because if we restart the container IP might change.

So i’m looking for a way to configure prometheus to add a tag with hostname.

Original configuration is :

```auto
  - job_name: 'node-exporter'
    dns_sd_configs:
    - names:
      - 'tasks.node-exporter'
      type: 'A'
      port: 9100

```

According to the documentation In understand we can use the swarm registry, but this is not working.

```auto
  - job_name: 'node-exporter'
    dockerswarm_sd_configs:
      - host: unix:///var/run/docker.sock
        role: tasks
        filters:
          - name: service
            values: ['monitoring_node-exporter']
    relabel_configs:
      - source_labels: [__meta_dockerswarm_task_name]
        regex: 'node-exporter\..*'
        action: keep

      - source_labels: [__meta_dockerswarm_task_container_port_publish]
        action: keep

      - source_labels: [__address__]
        target_label: __address__
        regex: '(.+):\d+'
        replacement: '${1}:9100'

      - source_labels: [__meta_dockerswarm_task_labels_prometheus_job]
        target_label: job
        replacement: $1
        action: replace

```

Do you have any idea on how I could setup this ?

best regards

---

<div class="post-metadata">

### Author: ![romgo](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@romgo](https://discuss.prometheus.io/u/romgo)
#### Post date: [February 9, 2026, 1:28pm UTC](https://discuss.prometheus.io/t/docker-swarm-node-exporter-host-name/3459/2 "2026-02-09T13:28:16Z")

</div>

to do this See [set instance name to physical host by hdep · Pull Request #241 · portainer/templates · GitHub](https://github.com/portainer/templates/pull/241)
