Skip to content

Commit

Permalink
Merge pull request #8711 from influxdata/jw-monitor-writes
Browse files Browse the repository at this point in the history
Batch up writes for monitor service
  • Loading branch information
jwilder authored Aug 16, 2017
2 parents 204d60c + ce90eca commit 3e1ce97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- [#8592](https://github.com/influxdata/influxdb/pull/8592): Mutex profiles are now available.
- [#8669](https://github.com/influxdata/influxdb/pull/8669): TSI Index Migration Tool
- [#7195](https://github.com/influxdata/influxdb/issues/7195): Support SHOW CARDINALITY queries.
- [#8711](https://github.com/influxdata/influxdb/pull/8711): Batch up writes for monitor service

### Bugfixes

Expand Down
15 changes: 12 additions & 3 deletions monitor/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,17 +440,26 @@ func (m *Monitor) storeStatistics() {
return
}

points := make(models.Points, 0, len(stats))
// Write all stats in batches
batch := make(models.Points, 0, 5000)
for _, s := range stats {
pt, err := models.NewPoint(s.Name, models.NewTags(s.Tags), s.Values, now)
if err != nil {
m.Logger.Info(fmt.Sprintf("Dropping point %v: %v", s.Name, err))
return
}
points = append(points, pt)
batch = append(batch, pt)
if len(batch) == cap(batch) {
m.writePoints(batch)
batch = batch[:0]

}
}

m.writePoints(points)
// Write the last batch
if len(batch) > 0 {
m.writePoints(batch)
}
case <-m.done:
m.Logger.Info(fmt.Sprintf("terminating storage of statistics"))
return
Expand Down

0 comments on commit 3e1ce97

Please sign in to comment.