Commit 627ff845 by Julien Pivotto

Adjust flag

Signed-off-by: 's avatarJulien Pivotto <roidelapluie@inuits.eu>
parent 6b618ecf
......@@ -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)
......
......@@ -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
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment