mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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
This commit is contained in:
parent
7a3f7e26ce
commit
d4a22cff0a
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user