3

I have setup my monitoring with the cadvisor, node-exporter, prometheus, grafana stack in my clustered environment using docker swarm.

What is the easiest way to get my actual hostnames picked up by node-exporter, so I can configure my dashboards to filter by node names in grafana?

For my kubernetes environments this works ootb, because all metrics are extended by the kubernetes_io_hostname, that contains the actual hostname.

The only solution to this I found, so far, was to introduce my own metric, that creates the combination between node ids and node names (like done by https://github.com/bvis/docker-node-exporter). But I really like to use the vanilla image (for update reasons, for example) and also mounting some file with the configuration on all machines seems to be too much effort to do this.

Is there an easy way to get the hostname of the node into my node-exporter metrics? Maybe by just mounting the hosts /etc/hostname file to a specific place in the node-exporter container, or something like that?

3

You just have to use the hostname on your docker compose file like this:

hostname: whatever-{{.Node.Hostname}}

Note that you have to prepend something to the hostname to avoid hostnames duplicates.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.