Prometheus: Interpolate vars in adhoc filters request (#94087)

* Interpolate vars in adhoc filters request

* interpolate variables on BE

---------

Co-authored-by: Kyle Brandt <kyle@grafana.com>
This commit is contained in:
Bogdan Matei
2024-10-01 18:33:06 +03:00
committed by GitHub
co-authored by Kyle Brandt
parent cbf8e7e679
commit a87df0528b
4 changed files with 29 additions and 7 deletions
+3 -3
View File
@@ -207,7 +207,7 @@ func Parse(span trace.Span, query backend.DataQuery, dsScrapeInterval string, in
// Interpolate variables in expr
timeRange := query.TimeRange.To.Sub(query.TimeRange.From)
expr := interpolateVariables(
expr := InterpolateVariables(
model.Expr,
query.Interval,
calculatedStep,
@@ -365,14 +365,14 @@ func calculateRateInterval(
return rateInterval
}
// interpolateVariables interpolates built-in variables
// InterpolateVariables interpolates built-in variables
// expr PromQL query
// queryInterval Requested interval in milliseconds. This value may be overridden by MinStep in query options
// calculatedStep Calculated final step value. It was calculated in calculatePrometheusInterval
// requestedMinStep Requested minimum step value. QueryModel.interval
// dsScrapeInterval Data source scrape interval in the config
// timeRange Requested time range for query
func interpolateVariables(
func InterpolateVariables(
expr string,
queryInterval time.Duration,
calculatedStep time.Duration,