Add hostname-specific tag only if not already part of tags

This commit is contained in:
Thomas Roehl 2022-10-07 18:50:28 +02:00
parent b973e8ac9c
commit 0b343171a7

View File

@ -281,7 +281,9 @@ func (r *metricRouter) Start() {
// Foward message received from collector channel // Foward message received from collector channel
coll_forward := func(p lp.CCMetric) { coll_forward := func(p lp.CCMetric) {
// receive from metric collector // receive from metric collector
if !p.HasTag(r.config.HostnameTagName) {
p.AddTag(r.config.HostnameTagName, r.hostname) p.AddTag(r.config.HostnameTagName, r.hostname)
}
if r.config.IntervalStamp { if r.config.IntervalStamp {
p.SetTime(r.timestamp) p.SetTime(r.timestamp)
} }
@ -310,7 +312,9 @@ func (r *metricRouter) Start() {
cache_forward := func(p lp.CCMetric) { cache_forward := func(p lp.CCMetric) {
// receive from metric collector // receive from metric collector
if !r.dropMetric(p) { if !r.dropMetric(p) {
if !p.HasTag(r.config.HostnameTagName) {
p.AddTag(r.config.HostnameTagName, r.hostname) p.AddTag(r.config.HostnameTagName, r.hostname)
}
forward(p) forward(p)
} }
} }