add tag "port" to every redis metric

see issue https://github.com/influxdb/telegraf/issues/74
This commit is contained in:
Evgeny Kulev 2015-07-23 00:55:03 +03:00
parent 6eb4bdcf0e
commit 014ddd76f4
1 changed files with 6 additions and 1 deletions

View File

@ -188,7 +188,12 @@ func (g *Redis) gatherServer(addr *url.URL, acc plugins.Accumulator) error {
continue 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]) val := strings.TrimSpace(parts[1])
ival, err := strconv.ParseUint(val, 10, 64) ival, err := strconv.ParseUint(val, 10, 64)