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

Use hostname instad of address in node selector #160

Open
kimdre opened this issue Feb 7, 2024 · 2 comments
Open

Use hostname instad of address in node selector #160

kimdre opened this issue Feb 7, 2024 · 2 comments

Comments

@kimdre
Copy link

kimdre commented Feb 7, 2024

I'm rather new to prometheus.
I specified the targets in my node exporter scrape_config with their private ip address instead of a hostname, so in the Node Exporter Full dashboard the node/instance selector also displays them like so. However the node_uname_info metric has a label nodename that contains their actual hostname.

Is there a way to change the selector so that it displays the nodename instead of address:port or can I somehow relabel the instance value so that it contains the nodename instead?

@vuanhson
Copy link

vuanhson commented Mar 25, 2024

+1, wish it showing hostname instead of IP address:port for someone that don't use fqdn for servers.

can I somehow relabel the instance value so that it contains the nodename instead

technically you can relabel it in prometheus config, but it make the query return wrong value so I don't think it doable

@mharbison72
Copy link

You could change the node variable to a "Series query", with the query value of node_uname_info{job="$job"}, and then add this to the Regex box: /nodename=\"(?<text>[^"]+)|instance=\"(?<value>[^\"]+)/g. That will cause the nodename value to be used as the display in the combobox, but the actual instance value used in the query under the hood is still IP:port.

The only caveat is a lot of Linux systems (RH based?) default to "localhost.localdomain", and I'm not aware of any way to conditionally fall back to IP address if the nodename isn't sane.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants