From 2e68bd14122c73364de84ae9f1ff710c93b74d9b Mon Sep 17 00:00:00 2001
From: Cameron Sparr <cameronsparr@gmail.com>
Date: Thu, 19 May 2016 10:01:19 +0100
Subject: [PATCH] don't overwrite host tags in plugins

closes #1227
closes #1210
---
 CHANGELOG.md         |  1 +
 agent/accumulator.go | 14 +++++++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9c0e9553..8c4088dd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@
 
 - [#1195](https://github.com/influxdata/telegraf/pull/1195): Docker panic on timeout. Thanks @zstyblik!
 - [#1211](https://github.com/influxdata/telegraf/pull/1211): mongodb input. Fix possible panic. Thanks @kols!
+- [#1228](https://github.com/influxdata/telegraf/pull/1228): Fix service plugin host tag overwrite.
 
 ## v0.13 [2016-05-11]
 
diff --git a/agent/accumulator.go b/agent/accumulator.go
index 70744359..6b2ffde2 100644
--- a/agent/accumulator.go
+++ b/agent/accumulator.go
@@ -84,13 +84,17 @@ func (ac *accumulator) AddFields(
 	if tags == nil {
 		tags = make(map[string]string)
 	}
-	// Apply daemon-wide tags if set
-	for k, v := range ac.defaultTags {
-		tags[k] = v
-	}
 	// Apply plugin-wide tags if set
 	for k, v := range ac.inputConfig.Tags {
-		tags[k] = v
+		if _, ok := tags[k]; !ok {
+			tags[k] = v
+		}
+	}
+	// Apply daemon-wide tags if set
+	for k, v := range ac.defaultTags {
+		if _, ok := tags[k]; !ok {
+			tags[k] = v
+		}
 	}
 	ac.inputConfig.Filter.FilterTags(tags)
 
-- 
GitLab