From 0ceb4f75658581116d2ed5df2d8c063963d6a2ed Mon Sep 17 00:00:00 2001 From: Roman Khavronenko Date: Sun, 25 Apr 2021 23:03:22 +0100 Subject: [PATCH] vmalert: keep the returned timestamp when persisting recording rule (#1245) Previously, vmalert used `lastExecTime` timestamp when writing recording rules to the remote storage. This may be incorrect, if vmalert uses `datasource.lookback` flag, which means rule's expression will be executed at some moment in the past. To avoid such situations, vmalert now will use returned timestamp instead of `lastExecTime`. --- app/vmalert/recording.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/vmalert/recording.go b/app/vmalert/recording.go index 4f075cdf12..5e8f780f07 100644 --- a/app/vmalert/recording.go +++ b/app/vmalert/recording.go @@ -100,7 +100,7 @@ func (rr *RecordingRule) Exec(ctx context.Context, q datasource.Querier, series duplicates := make(map[uint64]prompbmarshal.TimeSeries, len(qMetrics)) var tss []prompbmarshal.TimeSeries for _, r := range qMetrics { - ts := rr.toTimeSeries(r, rr.lastExecTime) + ts := rr.toTimeSeries(r, time.Unix(r.Timestamp, 0)) h := hashTimeSeries(ts) if _, ok := duplicates[h]; ok { rr.lastExecError = errDuplicate