Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do we have a way to get host names in metrics scrapped in Docker swarm #5410

Closed
saiharshitachava opened this Issue Mar 27, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@saiharshitachava
Copy link

saiharshitachava commented Mar 27, 2019

I am running node exporter as a global service in Docker swarm and I would like to get the hostnames in metrics scrapped using prometheus.

I'm currently using the A protocol in prometheus.yml which is giving me the container IP's .But I would need the hostnames of the instances as I have many hosts to monitor

I currently see them as below.

up{instance="10.0.33.243:8080",job="cadvisor_eng",monitor="codelab-monitor"} 1
up{instance="10.0.33.244:9100",job="node-exporter_eng",monitor="codelab-monitor"}

I would need hostnames instead of 10.0.33.243,10.0.33.244

Any help?

@simonpasquier

This comment has been minimized.

Copy link
Member

simonpasquier commented Apr 2, 2019

I suppose that you're using the DNS service discovery. You could use relabeling with __meta_dns_name provided that every target identifies uniquely by hostname + job.

relabel_configs:
- source_labels: [__meta_dns_name]
  action: replace
  target_label: instance

See also https://www.robustperception.io/controlling-the-instance-label

I'm closing it for now. If you have further questions, please use our user mailing list, which you can also search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.