From 014ddd76f423cd6e8ee8f4e7a39d4a189dda1cbd Mon Sep 17 00:00:00 2001 From: Evgeny Kulev Date: Thu, 23 Jul 2015 00:55:03 +0300 Subject: [PATCH] add tag "port" to every redis metric see issue https://github.com/influxdb/telegraf/issues/74 --- plugins/redis/redis.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/redis/redis.go b/plugins/redis/redis.go index 22f9cb076..d2f3dd374 100644 --- a/plugins/redis/redis.go +++ b/plugins/redis/redis.go @@ -188,7 +188,12 @@ func (g *Redis) gatherServer(addr *url.URL, acc plugins.Accumulator) error { continue } - tags := map[string]string{"host": addr.String()} + _, rPort, err := net.SplitHostPort(addr.Host) + if err != nil { + rPort = defaultPort + } + tags := map[string]string{"host": addr.String(), "port": rPort} + val := strings.TrimSpace(parts[1]) ival, err := strconv.ParseUint(val, 10, 64)