diff --git a/app/vmselect/prometheus/prometheus.go b/app/vmselect/prometheus/prometheus.go index c4f77473b1..d9c30caea1 100644 --- a/app/vmselect/prometheus/prometheus.go +++ b/app/vmselect/prometheus/prometheus.go @@ -790,6 +790,9 @@ func QueryHandler(qt *querytracer.Tracer, startTime time.Time, at *auth.Token, w start -= offset end := start start = end - window + if start < 0 { + start = 0 + } // Do not include data point with a timestamp matching the lower boundary of the window as Prometheus does. start++ if end < start { diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c02a220106..97c4e1ba2f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -15,6 +15,8 @@ The following tip changes can be tested by building VictoriaMetrics components f ## v1.87.x long-time support release (LTS) +* BUGFIX: [vmselect](https://docs.victoriametrics.com/vmselect.html): properly determine time range search for instant queries with too big look-behind window like `foo[100y]`. Previously, such queries could return empty responses even if `foo` is present in database. + ## [v1.87.13](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.87.13) Released at 2024-01-17