rfmoz / grafana-dashboards

Grafana dashboards
Apache License 2.0
1.16k stars 443 forks source link

Use hostname instad of address in node selector #160

Open kimdre opened 8 months ago

kimdre commented 8 months ago

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 commented 6 months ago

+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 commented 6 months ago

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.