Skip to content

Commit

Permalink
vmalert: keep the returned timestamp when persisting recording rule (V…
Browse files Browse the repository at this point in the history
…ictoriaMetrics#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`.
  • Loading branch information
hagen1778 authored Apr 25, 2021
1 parent d6f4497 commit 8701865
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/vmalert/recording.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8701865

Please sign in to comment.