Skip to content

Commit

Permalink
only count shard if it's non-empty
Browse files Browse the repository at this point in the history
closes #1221
  • Loading branch information
sparrc committed May 25, 2016
1 parent 9966099 commit 6351aa5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Bugfixes

- [#1252](https://github.com/influxdata/telegraf/pull/1252): Fix systemd service. Thanks @zbindenren!
- [#1221](https://github.com/influxdata/telegraf/pull/1221): Fix influxdb n_shards counter.

## v0.13.1 [2016-05-24]

Expand Down
8 changes: 4 additions & 4 deletions plugins/inputs/influxdb/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,16 @@ 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 {
continue
}

if p.Name == "shard" {
shardCounter++
}

// Add a tag to indicate the source of the data.
p.Tags["url"] = url

Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/influxdb/influxdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestInfluxDB(t *testing.T) {

acc.AssertContainsTaggedFields(t, "influxdb",
map[string]interface{}{
"n_shards": 2,
"n_shards": 1,
}, map[string]string{})
}

Expand Down

0 comments on commit 6351aa5

Please sign in to comment.