mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-10 07:34:04 -08:00
Regard in-memory series as new.
This commit ensures that series that exist only in-memory and not on-disk are not regarded as too old for operation exclusion.
This commit is contained in:
parent
81c406630a
commit
2d5de99fbf
|
@ -14,11 +14,12 @@
|
|||
package metric
|
||||
|
||||
import (
|
||||
"github.com/prometheus/prometheus/model"
|
||||
"github.com/prometheus/prometheus/utility"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/prometheus/model"
|
||||
"github.com/prometheus/prometheus/utility"
|
||||
)
|
||||
|
||||
// Assuming sample rate of 1 / 15Hz, this allows for one hour's worth of
|
||||
|
@ -370,6 +371,15 @@ func (s *memorySeriesStorage) GetMetricForFingerprint(f *model.Fingerprint) (mod
|
|||
return metric, nil
|
||||
}
|
||||
|
||||
func (s *memorySeriesStorage) HasFingerprint(f *model.Fingerprint) bool {
|
||||
s.RLock()
|
||||
defer s.RUnlock()
|
||||
|
||||
_, has := s.fingerprintToSeries[*f]
|
||||
|
||||
return has
|
||||
}
|
||||
|
||||
func (s *memorySeriesStorage) CloneSamples(f *model.Fingerprint) model.Values {
|
||||
s.RLock()
|
||||
defer s.RUnlock()
|
||||
|
|
|
@ -309,20 +309,35 @@ func (t *TieredStorage) seriesTooOld(f *model.Fingerprint, i time.Time) (bool, e
|
|||
// BUG(julius): Make this configurable by query layer.
|
||||
i = i.Add(-stalenessLimit)
|
||||
|
||||
wm, ok := t.wmCache.Get(f)
|
||||
if !ok {
|
||||
wm, cacheHit := t.wmCache.Get(f)
|
||||
if !cacheHit {
|
||||
value := &dto.MetricHighWatermark{}
|
||||
present, err := t.DiskStorage.MetricHighWatermarks.Get(f.ToDTO(), value)
|
||||
diskHit, err := t.DiskStorage.MetricHighWatermarks.Get(f.ToDTO(), value)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if present {
|
||||
|
||||
if diskHit {
|
||||
wmTime := time.Unix(*value.Timestamp, 0).UTC()
|
||||
t.wmCache.Set(f, &Watermarks{High: wmTime})
|
||||
return wmTime.Before(i), nil
|
||||
}
|
||||
return true, nil
|
||||
|
||||
if !t.memoryArena.HasFingerprint(f) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
samples := t.memoryArena.CloneSamples(f)
|
||||
if len(samples) == 0 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
newest := samples[0].Timestamp
|
||||
t.wmCache.Set(f, &Watermarks{High: newest})
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return wm.High.Before(i), nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue