From d0633717eafc21d8e303f7435454eec7ea6aae9f Mon Sep 17 00:00:00 2001 From: kongfei605 Date: Wed, 23 Oct 2024 16:18:10 +0800 Subject: [PATCH] fix: subscription options for gnmi (#1080) --- inputs/gnmi/handler.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/inputs/gnmi/handler.go b/inputs/gnmi/handler.go index 41803559..2c9fdf43 100644 --- a/inputs/gnmi/handler.go +++ b/inputs/gnmi/handler.go @@ -263,9 +263,16 @@ func (h *handler) handleSubscribeResponseUpdate(slist *types.SampleList, respons } value := field.value disableConcatenating := false + base := field.path.String() for _, sub := range h.subs { - base, _ := field.path.split() - if strings.HasSuffix(base, sub.Path) { + subPath := sub.Path + if len(strings.Split(base, ":")) >= 2 { + // origin is not null + if sub.Origin != "" { + subPath = sub.Origin + ":" + sub.Path + } + } + if strings.HasPrefix(base, subPath) { // field.path => origin:path // sub.path => path disableConcatenating = sub.DisableConcatenation