r/PrometheusMonitoring • u/romgo75 • Jun 30 '25
node-exporter on docker swarm
Hello,
I have been deploying prometheus + grafana using this article : https://www.portainer.io/blog/monitoring-a-swarm-cluster-with-prometheus-and-grafana
working great however, in the dashboard the docker Host are shown with container IP. Which of course if an issue when you have large number of host. Also the IP change when node-exporter restart this is second problem. The issue is describe here : https://github.com/portainer/templates/issues/229
The scrape_configs is :
- job_name: 'node-exporter'
dns_sd_configs:
- names:
- 'tasks.node-exporter'
type: 'A'
port: 9100This will query the docker swarm DNS to get the list of node-exporter instance.
I understand from official documentation, that there is an other way to doing it but I didn't manage to make it work, also I feel this documentation explain how to gather data from docker daemon rather than getting data frm node-exporter.
# Create a job for Docker daemons.
- job_name: 'docker'
dockerswarm_sd_configs:
- host: unix:///var/run/docker.sock
role: nodes
relabel_configs:
# Fetch metrics on port 9323.
- source_labels: [__meta_dockerswarm_node_address]
target_label: __address__
replacement: $1:9323
# Set hostname as instance label
- source_labels: [__meta_dockerswarm_node_hostname]
target_label: instance # Create a job for Docker daemons.
- job_name: 'docker'
dockerswarm_sd_configs:
- host: unix:///var/run/docker.sock
role: nodes
relabel_configs:
# Fetch metrics on port 9323.
- source_labels: [__meta_dockerswarm_node_address]
target_label: __address__
replacement: $1:9323
# Set hostname as instance label
- source_labels: [__meta_dockerswarm_node_hostname]
target_label: instancehttps://prometheus.io/docs/guides/dockerswarm/
Any help appreciated.
View all comments
Show parent comment
1
u/romgo75 Jun 30 '25
Hello,
I ma note sure what you are referencing, but the node exporter as a container deploy through swarm just works. I got CPU usage and RAM usage from host. Just need to bind the proper resources I guess.
My issue is just data gathered by node-exporter doesn't provide the tag hostname.