diff --git a/models/running_aggregator.go b/models/running_aggregator.go index 50c76fb7f..d0012ffc0 100644 --- a/models/running_aggregator.go +++ b/models/running_aggregator.go @@ -177,6 +177,17 @@ func (r *RunningAggregator) Push(acc telegraf.Accumulator) { since := r.periodEnd until := r.periodEnd.Add(r.Config.Period) + + // Check if the next aggregation window will contain "now". This might + // not be the case if the machine's clock was adjusted or the machine + // hibernated as in those cases the clock might be advanced before or + // after the initial aggregation window. + nowWall := time.Now().Truncate(-1) + if nowWall.Before(since.Truncate(-1)) || nowWall.After(until.Truncate(-1)) { + since = nowWall.Truncate(r.Config.Period) + until = since.Add(r.Config.Period) + } + r.UpdateWindow(since, until) start := time.Now()