influxdb input: Add shard counter

closes #1221
This commit is contained in:
Cameron Sparr
2016-05-18 19:31:36 +01:00
parent e94e50181c
commit b065573e23
3 changed files with 90 additions and 64 deletions

View File

@@ -120,6 +120,9 @@ func (i *InfluxDB) gatherURL(
acc telegraf.Accumulator,
url string,
) error {
shardCounter := 0
now := time.Now()
resp, err := client.Get(url)
if err != nil {
return err
@@ -201,6 +204,10 @@ func (i *InfluxDB) gatherURL(
continue
}
if p.Name == "shard" {
shardCounter++
}
// If the object was a point, but was not fully initialized,
// ignore it and move on.
if p.Name == "" || p.Tags == nil || p.Values == nil || len(p.Values) == 0 {
@@ -214,9 +221,18 @@ func (i *InfluxDB) gatherURL(
"influxdb_"+p.Name,
p.Values,
p.Tags,
now,
)
}
acc.AddFields("influxdb",
map[string]interface{}{
"n_shards": shardCounter,
},
nil,
now,
)
return nil
}