From 78b1a0e77127379c6e477e95acc7c0fc57df12b8 Mon Sep 17 00:00:00 2001 From: gunnaraasen Date: Tue, 13 Dec 2016 15:16:29 -0800 Subject: [PATCH] Add stats on dropped measurements and series; Fixes #7697 --- tsdb/meta.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tsdb/meta.go b/tsdb/meta.go index 178a5af8c84..bc4013b9ce8 100644 --- a/tsdb/meta.go +++ b/tsdb/meta.go @@ -20,8 +20,10 @@ import ( //go:generate protoc --gogo_out=. internal/meta.proto const ( - statDatabaseSeries = "numSeries" // number of series in this database - statDatabaseMeasurements = "numMeasurements" // number of measurements in this database + statDatabaseSeries = "numSeries" // number of series in this database + statDatabaseMeasurements = "numMeasurements" // number of measurements in this database + statDatabaseSeriesDropped = "numSeriesDropped" // number of series dropped from database + statDatabaseMeasurementsDropped = "numMeasurementsDropped" // number of measurements dropped from database ) // DatabaseIndex is the in memory index of a collection of measurements, time series, and their tags. @@ -52,8 +54,10 @@ func NewDatabaseIndex(name string) *DatabaseIndex { // IndexStatistics maintains statistics for the index. type IndexStatistics struct { - NumSeries int64 - NumMeasurements int64 + NumSeries int64 + NumMeasurements int64 + NumSeriesDropped int64 + NumMeasurementsDropped int64 } // Statistics returns statistics for periodic monitoring. @@ -62,8 +66,10 @@ func (d *DatabaseIndex) Statistics(tags map[string]string) []models.Statistic { Name: "database", Tags: d.defaultTags.Merge(tags), Values: map[string]interface{}{ - statDatabaseSeries: atomic.LoadInt64(&d.stats.NumSeries), - statDatabaseMeasurements: atomic.LoadInt64(&d.stats.NumMeasurements), + statDatabaseSeries: atomic.LoadInt64(&d.stats.NumSeries), + statDatabaseMeasurements: atomic.LoadInt64(&d.stats.NumMeasurements), + statDatabaseSeriesDropped: atomic.LoadInt64(&d.stats.NumSeriesDropped), + statDatabaseMeasurementsDropped: atomic.LoadInt64(&d.stats.NumMeasurementsDropped), }, }} } @@ -244,6 +250,7 @@ func (d *DatabaseIndex) UnassignShard(k string, shardID uint64) { d.mu.Lock() delete(d.series, k) atomic.AddInt64(&d.stats.NumSeries, -1) + atomic.AddInt64(&d.stats.NumSeriesDropped, 1) d.mu.Unlock() } } @@ -491,7 +498,9 @@ func (d *DatabaseIndex) dropMeasurement(name string) { } atomic.AddInt64(&d.stats.NumSeries, int64(-len(m.seriesByID))) + atomic.AddInt64(&d.stats.NumSeriesDropped, int64(len(m.seriesByID))) atomic.AddInt64(&d.stats.NumMeasurements, -1) + atomic.AddInt64(&d.stats.NumMeasurementsDropped, 1) } // DropSeries removes the series keys and their tags from the index @@ -524,6 +533,7 @@ func (d *DatabaseIndex) DropSeries(keys []string) { d.dropMeasurement(mname) } atomic.AddInt64(&d.stats.NumSeries, -nDeleted) + atomic.AddInt64(&d.stats.NumSeriesDropped, nDeleted) } // Dereference removes all references to data within b and moves them to the heap.