From fbd54e84a2c5b4355b92a4ade0fd50805a5bff7e Mon Sep 17 00:00:00 2001 From: David Bennett <71459415+Jagularr@users.noreply.github.com> Date: Wed, 13 Jan 2021 15:48:21 -0500 Subject: [PATCH] GNMI plugin should not take off the first character of field keys when no 'alias path' exists. (#8659) * GNMI plugin should not take off the first character of field keys when no 'alias path' exists. * fix test method name * fix test file formatting * fix test file formatting * Remove my unnecessary failing test --- plugins/inputs/gnmi/gnmi.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/inputs/gnmi/gnmi.go b/plugins/inputs/gnmi/gnmi.go index 694ca7851..5e99092f8 100644 --- a/plugins/inputs/gnmi/gnmi.go +++ b/plugins/inputs/gnmi/gnmi.go @@ -290,11 +290,11 @@ func (c *GNMI) handleSubscribeResponseUpdate(address string, response *gnmi.Subs // Group metrics for k, v := range fields { key := k - if len(aliasPath) < len(key) { + if len(aliasPath) < len(key) && len(aliasPath) != 0 { // This may not be an exact prefix, due to naming style // conversion on the key. key = key[len(aliasPath)+1:] - } else { + } else if len(aliasPath) >= len(key) { // Otherwise use the last path element as the field key. key = path.Base(key)