From ef8e3eb9b33f5dc4becb9598818934fbe93b5a97 Mon Sep 17 00:00:00 2001 From: Haleygo Date: Fri, 7 Jul 2023 17:48:05 +0800 Subject: [PATCH] vmselect: fix result in Prometheus query when time is small (#4578) vmselect: fix result in Prometheus query when time is small Co-authored-by: Roman Khavronenko --- app/vmselect/promql/eval.go | 3 +++ docs/CHANGELOG.md | 1 + 2 files changed, 4 insertions(+) diff --git a/app/vmselect/promql/eval.go b/app/vmselect/promql/eval.go index 7f7dc90a0a..fc1b4cefb6 100644 --- a/app/vmselect/promql/eval.go +++ b/app/vmselect/promql/eval.go @@ -1100,6 +1100,9 @@ func evalRollupFuncWithMetricExpr(qt *querytracer.Tracer, ec *EvalConfig, funcNa } else { minTimestamp -= ec.Step } + if minTimestamp < 0 { + minTimestamp = 0 + } sq := storage.NewSearchQuery(ec.AuthToken.AccountID, ec.AuthToken.ProjectID, minTimestamp, ec.End, tfss, ec.MaxSeries) rss, isPartial, err := netstorage.ProcessSearchQuery(qt, ec.DenyPartialResponse, sq, ec.Deadline) if err != nil { diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index f438479b98..2cdd7c8266 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -50,6 +50,7 @@ The following tip changes can be tested by building VictoriaMetrics components f * BUGFIX: add validation for invalid [partial RFC3339 timestamp formats](https://docs.victoriametrics.com/Single-server-VictoriaMetrics.html#timestamp-formats) in query and export APIs. * BUGFIX: [vmctl](https://docs.victoriametrics.com/vmctl.html): interrupt explore procedure in influx mode if vmctl found no numeric fields. * BUGFIX: [vmalert](https://docs.victoriametrics.com/vmalert.html): use RFC3339 time format in query args instead of unix timestamp for all issued queries to Prometheus-like datasources. +* BUGFIX: vmselect: fix timestamp alignment for Prometheus querying API if time argument is less than 10m from the beginning of Unix epoch. ## [v1.91.3](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.91.3)