Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1532 from grafana/correct_for_delayed_lastUpdate
Browse files Browse the repository at this point in the history
correct for delayed lastUpdate updates
  • Loading branch information
Dieterbe authored Nov 14, 2019
2 parents 7044f44 + e572c15 commit dd68019
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions idx/bigtable/bigtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,17 @@ func (b *BigtableIdx) updateBigtable(now uint32, inMemory bool, archive idx.Arch
return archive
}

func (b *BigtableIdx) Find(orgId uint32, pattern string, from int64) ([]idx.Node, error) {
// The lastUpdate timestamp does not get updated in the bigtable index every time when
// a data point is received, there can be a delay of up to b.cfg.updateInterval32. To
// avoid falsely excluding a metric based on its lastUpdate timestamp we offset the
// from time by updateInterval32, this way we err on the "too inclusive" side
if from > int64(b.cfg.updateInterval32) {
from -= int64(b.cfg.updateInterval32)
}
return b.MemoryIndex.Find(orgId, pattern, from)
}

func (b *BigtableIdx) rebuildIndex() {
log.Info("bigtable-idx: Rebuilding Memory Index from metricDefinitions in bigtable")
pre := time.Now()
Expand Down
11 changes: 11 additions & 0 deletions idx/cassandra/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,17 @@ func (c *CasIdx) updateCassandra(now uint32, inMemory bool, archive idx.Archive,
return archive
}

func (c *CasIdx) Find(orgId uint32, pattern string, from int64) ([]idx.Node, error) {
// The lastUpdate timestamp does not get updated in the cassandra index every time when
// a data point is received, there can be a delay of up to c.updateInterval32. To avoid
// falsely excluding a metric based on its lastUpdate timestamp we offset the from time
// by updateInterval32, this way we err on the "too inclusive" side
if from > int64(c.updateInterval32) {
from -= int64(c.updateInterval32)
}
return c.MemoryIndex.Find(orgId, pattern, from)
}

func (c *CasIdx) rebuildIndex() {
log.Info("cassandra-idx: Rebuilding Memory Index from metricDefinitions in Cassandra")
pre := time.Now()
Expand Down

0 comments on commit dd68019

Please sign in to comment.