Backfill: Do not query after --end
@@ -105,11 +105,15 @@ func (importer *ruleImporter) importRule(ctx context.Context, ruleExpr, ruleName
for startWithAlignment.Unix() < currStart {
startWithAlignment = startWithAlignment.Add(grp.Interval())
}
+ end := time.Unix(min(endOfBlock/int64(time.Second/time.Millisecond), end.Unix()), 0).UTC()
+ if end.Before(startWithAlignment) {
+ break
+ }
val, warnings, err := importer.apiClient.QueryRange(ctx,
ruleExpr,
v1.Range{
Start: startWithAlignment,
- End: time.Unix(min(endOfBlock/int64(time.Second/time.Millisecond), end.Unix()), 0).UTC(),
+ End: end,
Step: grp.Interval(),
},
)
