diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index 5587f0cb3..63ea99eab 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -239,8 +239,8 @@ func main() { a.Flag("rules.alert.resend-delay", "Minimum amount of time to wait before resending an alert to Alertmanager."). Default("1m").SetValue(&cfg.resendDelay) - a.Flag("scrape.timestamp-tolerance", "Adjust scrape timestamps by up to this amount to align them to the intended schedule. Experimental."). - Hidden().Default("2ms").DurationVar(&scrape.ScrapeTimestampTolerance) + a.Flag("scrape.adjust-timestamps", "Adjust scrape timestamps by up to 2ms to align them to the intended schedule. Experimental."). + Hidden().Default("true").BoolVar(&scrape.AlignScrapeTimestamps) a.Flag("alertmanager.notification-queue-capacity", "The capacity of the queue for pending Alertmanager notifications."). Default("10000").IntVar(&cfg.notifier.QueueCapacity) diff --git a/scrape/scrape.go b/scrape/scrape.go index 53d573fcc..900c99137 100644 --- a/scrape/scrape.go +++ b/scrape/scrape.go @@ -50,7 +50,10 @@ import ( // Temporary tolerance for scrape appends timestamps alignment, to enable better // compression at the TSDB level. // See https://github.com/prometheus/prometheus/issues/7846 -var ScrapeTimestampTolerance = 2 * time.Millisecond +const scrapeTimestampTolerance = 2 * time.Millisecond + +// Enable or disable the tolerance for scrape described above. +var AlignScrapeTimestamps = true var errNameLabelMandatory = fmt.Errorf("missing metric name (%s label)", labels.MetricName) @@ -1009,14 +1012,14 @@ mainLoop: // increase in TSDB. // See https://github.com/prometheus/prometheus/issues/7846 scrapeTime := time.Now() - if interval > 100*ScrapeTimestampTolerance { + if AlignScrapeTimestamps && interval > 100*scrapeTimestampTolerance { // For some reason, a tick might have been skipped, in which case we // would call alignedScrapeTime.Add(interval) multiple times. for scrapeTime.Sub(alignedScrapeTime) >= interval { alignedScrapeTime = alignedScrapeTime.Add(interval) } // Align the scrape time if we are in the tolerance boundaries. - if scrapeTime.Sub(alignedScrapeTime) <= ScrapeTimestampTolerance { + if scrapeTime.Sub(alignedScrapeTime) <= scrapeTimestampTolerance { scrapeTime = alignedScrapeTime } }