Add MySQL server address tag to all measurements

Closes #138
This commit is contained in:
Cameron Sparr 2015-08-25 13:18:33 -06:00
parent 8a6665c03f
commit 94eed9b43c
3 changed files with 14 additions and 4 deletions

View File

@ -4,6 +4,7 @@
- [#133](https://github.com/influxdb/telegraf/pull/133): Add plugin.Gather error logging. Thanks @nickscript0! - [#133](https://github.com/influxdb/telegraf/pull/133): Add plugin.Gather error logging. Thanks @nickscript0!
- [#136](https://github.com/influxdb/telegraf/issues/136): Add a -usage flag for printing usage of a single plugin. - [#136](https://github.com/influxdb/telegraf/issues/136): Add a -usage flag for printing usage of a single plugin.
- [#137](https://github.com/influxdb/telegraf/issues/137): Memcached: fix when a value contains a space - [#137](https://github.com/influxdb/telegraf/issues/137): Memcached: fix when a value contains a space
- [#138](https://github.com/influxdb/telegraf/issues/138): MySQL server address tag.
### Bugfixes ### Bugfixes
- [#128](https://github.com/influxdb/telegraf/issues/128): system_load measurement missing. - [#128](https://github.com/influxdb/telegraf/issues/128): system_load measurement missing.

View File

@ -109,7 +109,7 @@ func (m *Memcached) gatherServer(address string, acc plugins.Accumulator) error
values[string(s[1])] = string(s[2]) values[string(s[1])] = string(s[2])
} }
// // Add server address as a tag
tags := map[string]string{"server": address} tags := map[string]string{"server": address}
// Process values // Process values

View File

@ -111,10 +111,19 @@ func (m *Mysql) gatherServer(serv string, acc plugins.Accumulator) error {
var found bool var found bool
// Parse out user/password from server address tag if given
var servtag string
if strings.Contains(serv, "@") {
servtag = strings.Split(serv, "@")[1]
} else {
servtag = serv
}
tags := map[string]string{"server": servtag}
for _, mapped := range mappings { for _, mapped := range mappings {
if strings.HasPrefix(name, mapped.onServer) { if strings.HasPrefix(name, mapped.onServer) {
i, _ := strconv.Atoi(string(val.([]byte))) i, _ := strconv.Atoi(string(val.([]byte)))
acc.Add(mapped.inExport+name[len(mapped.onServer):], i, nil) acc.Add(mapped.inExport+name[len(mapped.onServer):], i, tags)
found = true found = true
} }
} }
@ -130,14 +139,14 @@ func (m *Mysql) gatherServer(serv string, acc plugins.Accumulator) error {
return err return err
} }
acc.Add("queries", i, nil) acc.Add("queries", i, tags)
case "Slow_queries": case "Slow_queries":
i, err := strconv.ParseInt(string(val.([]byte)), 10, 64) i, err := strconv.ParseInt(string(val.([]byte)), 10, 64)
if err != nil { if err != nil {
return err return err
} }
acc.Add("slow_queries", i, nil) acc.Add("slow_queries", i, tags)
} }
} }