Skip to content

Use local hostname when remote hostengine is on loopback#697

Open
skartikey wants to merge 1 commit into
NVIDIA:mainfrom
skartikey:fix/issue-572-loopback-hostname
Open

Use local hostname when remote hostengine is on loopback#697
skartikey wants to merge 1 commit into
NVIDIA:mainfrom
skartikey:fix/issue-572-loopback-hostname

Conversation

@skartikey

Copy link
Copy Markdown

In v4 the hostname label 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 example
localhost:5556 or 127.0.0.1:5556), the label ends up being localhost / 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)
  • IPv4 loopback 127.0.0.0/8
  • IPv6 loopback ::1
  • bracketed and port-suffixed forms ([::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 honors NODE_NAME first, then os.Hostname(), identical to the existing local path.

Closes #572

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>
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

Successfully merging this pull request may close these issues.

Changing the NV-Hostengine port will result in Hostname label to always be localhost

1 participant