diff --git a/cmd/promtool/rules.go b/cmd/promtool/rules.go index 890e2f287..7140d8aa9 100644 --- a/cmd/promtool/rules.go +++ b/cmd/promtool/rules.go @@ -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(), }, )