mirror of
https://github.com/prometheus/prometheus
synced 2024-12-23 23:13:11 +00:00
Introduce timestamp tolerance in scrapes
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
This commit is contained in:
parent
8dbfa14607
commit
6544f95403
@ -47,6 +47,11 @@ import (
|
||||
"github.com/prometheus/prometheus/storage"
|
||||
)
|
||||
|
||||
// Temporary tolerance for scrape appends timestamps alignment, to enable better
|
||||
// compression at the TSDB level.
|
||||
// See https://github.com/prometheus/prometheus/issues/7846
|
||||
const scrapeTimestampTolerance = 2 * time.Millisecond
|
||||
|
||||
var errNameLabelMandatory = fmt.Errorf("missing metric name (%s label)", labels.MetricName)
|
||||
|
||||
var (
|
||||
@ -1033,6 +1038,16 @@ func (sl *scrapeLoop) scrapeAndReport(interval, timeout time.Duration, last time
|
||||
)
|
||||
}
|
||||
|
||||
// Temporary workaround for a jitter in go timers that causes disk space
|
||||
// increase in TSDB.
|
||||
// See https://github.com/prometheus/prometheus/issues/7846
|
||||
if last.IsZero() && interval > 100*scrapeTimestampTolerance {
|
||||
exactStart := last.Add(interval)
|
||||
if t := start.Sub(exactStart); t >= -scrapeTimestampTolerance && t <= scrapeTimestampTolerance {
|
||||
start = exactStart
|
||||
}
|
||||
}
|
||||
|
||||
b := sl.buffers.Get(sl.lastScrapeSize).([]byte)
|
||||
defer sl.buffers.Put(b)
|
||||
buf := bytes.NewBuffer(b)
|
||||
|
Loading…
Reference in New Issue
Block a user