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

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

View File

@@ -111,10 +111,19 @@ func (m *Mysql) gatherServer(serv string, acc plugins.Accumulator) error {
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 {
if strings.HasPrefix(name, mapped.onServer) {
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
}
}
@@ -130,14 +139,14 @@ func (m *Mysql) gatherServer(serv string, acc plugins.Accumulator) error {
return err
}
acc.Add("queries", i, nil)
acc.Add("queries", i, tags)
case "Slow_queries":
i, err := strconv.ParseInt(string(val.([]byte)), 10, 64)
if err != nil {
return err
}
acc.Add("slow_queries", i, nil)
acc.Add("slow_queries", i, tags)
}
}