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 :
- 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.
- 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