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`.
This commit is contained in:
Roman Khavronenko 2021-04-25 23:03:22 +01:00 committed by Aliaksandr Valialkin
parent 2357e21024
commit 0ceb4f7565

View file

@ -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