From 439a3a6fe83494d0c26b7ffd45e8bbbfa595fa52 Mon Sep 17 00:00:00 2001 From: Ulric Qin Date: Thu, 28 Jul 2022 19:04:48 +0800 Subject: [PATCH] switch_legacy: add ip label in custom metrics --- inputs/switch_legacy/switch_legacy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inputs/switch_legacy/switch_legacy.go b/inputs/switch_legacy/switch_legacy.go index 3b9faef..15a5d63 100644 --- a/inputs/switch_legacy/switch_legacy.go +++ b/inputs/switch_legacy/switch_legacy.go @@ -203,7 +203,7 @@ func (ins *Instance) custstat(wg *sync.WaitGroup, ip string, slist *types.Sample if len(snmpPDUs) > 0 && err == nil { value, err = conv.ToFloat64(snmpPDUs[0].Value) if err == nil { - slist.PushFront(types.NewSample(inputName, cust.Metric, value, cust.Tags)) + slist.PushFront(types.NewSample(inputName, cust.Metric, value, cust.Tags, map[string]string{ins.parent.SwitchIdLabel: ins.parent.MappingIP(ip)})) } else { log.Println("E! failed to convert to float64, ip:", ip, "oid:", cust.OID, "value:", snmpPDUs[0].Value) }