From b240096688b5abb606b4bc8d0f2ad79d2e4160ec Mon Sep 17 00:00:00 2001 From: Josh Powers Date: Mon, 29 Jan 2024 07:26:30 -0700 Subject: [PATCH] fix(inputs.vsphere): Use guest.guestId value if set for guest name fixes: #14616 --- plugins/inputs/vsphere/endpoint.go | 3 +++ plugins/inputs/vsphere/finder.go | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/inputs/vsphere/endpoint.go b/plugins/inputs/vsphere/endpoint.go index 2c8cd1ead5103..a99c4c2771020 100644 --- a/plugins/inputs/vsphere/endpoint.go +++ b/plugins/inputs/vsphere/endpoint.go @@ -840,6 +840,9 @@ func getVMs(ctx context.Context, e *Endpoint, resourceFilter *ResourceFilter) (o // Sometimes Config is unknown and returns a nil pointer if r.Config != nil { guest = cleanGuestID(r.Config.GuestId) + if r.Guest.GuestId != "" { + guest = cleanGuestID(r.Guest.GuestId) + } uuid = r.Config.Uuid } cvs := make(map[string]string) diff --git a/plugins/inputs/vsphere/finder.go b/plugins/inputs/vsphere/finder.go index e9bdd5d96ed0d..8928f74bd85cc 100644 --- a/plugins/inputs/vsphere/finder.go +++ b/plugins/inputs/vsphere/finder.go @@ -258,7 +258,8 @@ func init() { "HostSystem": {"parent", "summary.customValue", "customValue"}, "ResourcePool": {"parent", "customValue"}, "VirtualMachine": {"runtime.host", "config.guestId", "config.uuid", "runtime.powerState", - "summary.customValue", "guest.net", "guest.hostName", "resourcePool", "customValue"}, + "summary.customValue", "guest.guestId", "guest.net", "guest.hostName", "resourcePool", + "customValue"}, "Datastore": {"parent", "info", "customValue"}, "ClusterComputeResource": {"parent", "customValue"}, "Datacenter": {"parent", "customValue"},