Use local hostname when remote hostengine is on loopback#697
Open
skartikey wants to merge 1 commit into
Open
Conversation
The hostname label was set to the host portion of the remote hostengine address (-r). When connecting to a hostengine on a non-default port on the local node (e.g. localhost:5556 or 127.0.0.1:5556), the label became localhost / 127.0.0.1, making it impossible to filter metrics by node in dashboards. Detect loopback remote addresses (localhost, 127.0.0.0/8, ::1, including bracketed and ported forms) and fall back to the local hostname (NODE_NAME or os.Hostname()), consistent with the Kubernetes path. Closes NVIDIA#572 Signed-off-by: skartikey <1942366+skartikey@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In v4 the
hostnamelabel is derived from the host portion of the remote hostengine address passed via-r/DCGM_REMOTE_HOSTENGINE_INFO. When the hostengine runs on the local node but on a non-default port (for examplelocalhost:5556or127.0.0.1:5556), the label ends up beinglocalhost/127.0.0.1. That makes it impossible to distinguish or filter metrics by node in Grafana dashboards.This change detects loopback remote addresses and falls back to the local hostname, matching the behavior the exporter already uses for the Kubernetes path.
Loopback detection covers:
localhost(case-insensitive)127.0.0.0/8::1[::1]:5555,127.0.0.1:5556, ...)Non-loopback hosts (
example.com, public IPv4/IPv6, the unspecified address::) are unaffected and still used verbatim. The fallback honorsNODE_NAMEfirst, thenos.Hostname(), identical to the existing local path.Closes #572