[v9.5.x] Prometheus: Fix regression for $__rate_interval comparison (#67505)
Prometheus: Fix regression for $__rate_interval comparison (#67460)
* fix , comparison regression
* intervalMs was not pressent before the regression and this value changes the adjusted interval calculating giving a false positive in favor of the regression
(cherry picked from commit d4a22cff0a)
Co-authored-by: Brendan O'Handley <brendan.ohandley@grafana.com>
This commit is contained in:
co-authored by
Brendan O'Handley
parent
8e7f6c231a
commit
ff79e2df57
@@ -156,6 +156,10 @@ func calculatePrometheusInterval(
|
||||
query backend.DataQuery,
|
||||
intervalCalculator intervalv2.Calculator,
|
||||
) (time.Duration, error) {
|
||||
// we need to compare the original query model after it is overwritten below to variables so that we can
|
||||
// calculate the rateInterval if it is equal to $__rate_interval or ${__rate_interval}
|
||||
originalQueryInterval := queryInterval
|
||||
|
||||
// If we are using variable for interval/step, we will replace it with calculated interval
|
||||
if isVariableInterval(queryInterval) {
|
||||
queryInterval = ""
|
||||
@@ -173,7 +177,8 @@ func calculatePrometheusInterval(
|
||||
adjustedInterval = calculatedInterval.Value
|
||||
}
|
||||
|
||||
if queryInterval == varRateInterval || queryInterval == varRateIntervalAlt {
|
||||
// here is where we compare for $__rate_interval or ${__rate_interval}
|
||||
if originalQueryInterval == varRateInterval || originalQueryInterval == varRateIntervalAlt {
|
||||
// Rate interval is final and is not affected by resolution
|
||||
return calculateRateInterval(adjustedInterval, timeInterval, intervalCalculator), nil
|
||||
} else {
|
||||
|
||||
@@ -376,7 +376,6 @@ func TestParse(t *testing.T) {
|
||||
"format": "time_series",
|
||||
"intervalFactor": 1,
|
||||
"interval": "$__rate_interval",
|
||||
"intervalMs": 60000,
|
||||
"refId": "A"
|
||||
}`, timeRange)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user