From 0b343171a724c78b47ff9bbb0092ec8eb03a4fdc Mon Sep 17 00:00:00 2001 From: Thomas Roehl Date: Fri, 7 Oct 2022 18:50:28 +0200 Subject: [PATCH] Add hostname-specific tag only if not already part of tags --- internal/metricRouter/metricRouter.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/metricRouter/metricRouter.go b/internal/metricRouter/metricRouter.go index 2614ced..8acb345 100644 --- a/internal/metricRouter/metricRouter.go +++ b/internal/metricRouter/metricRouter.go @@ -281,7 +281,9 @@ func (r *metricRouter) Start() { // Foward message received from collector channel coll_forward := func(p lp.CCMetric) { // receive from metric collector - p.AddTag(r.config.HostnameTagName, r.hostname) + if !p.HasTag(r.config.HostnameTagName) { + p.AddTag(r.config.HostnameTagName, r.hostname) + } if r.config.IntervalStamp { p.SetTime(r.timestamp) } @@ -310,7 +312,9 @@ func (r *metricRouter) Start() { cache_forward := func(p lp.CCMetric) { // receive from metric collector if !r.dropMetric(p) { - p.AddTag(r.config.HostnameTagName, r.hostname) + if !p.HasTag(r.config.HostnameTagName) { + p.AddTag(r.config.HostnameTagName, r.hostname) + } forward(p) } }