Use last path element as field key if path fully specified (#6848)
This commit is contained in:
@@ -280,11 +280,26 @@ func (c *CiscoTelemetryGNMI) handleSubscribeResponse(address string, reply *gnmi
|
||||
}
|
||||
|
||||
// Group metrics
|
||||
for key, val := range fields {
|
||||
if len(aliasPath) > 0 {
|
||||
for k, v := range fields {
|
||||
key := k
|
||||
if len(aliasPath) < len(key) {
|
||||
// This may not be an exact prefix, due to naming style
|
||||
// conversion on the key.
|
||||
key = key[len(aliasPath)+1:]
|
||||
} else {
|
||||
// Otherwise use the last path element as the field key.
|
||||
key = path.Base(key)
|
||||
|
||||
// If there are no elements skip the item; this would be an
|
||||
// invalid message.
|
||||
key = strings.TrimLeft(key, "/.")
|
||||
if key == "" {
|
||||
c.Log.Errorf("invalid empty path: %q", k)
|
||||
continue
|
||||
}
|
||||
}
|
||||
grouper.Add(name, tags, timestamp, key, val)
|
||||
|
||||
grouper.Add(name, tags, timestamp, key, v)
|
||||
}
|
||||
|
||||
lastAliasPath = aliasPath
|
||||
|
||||
Reference in New Issue
Block a user