Prometheus: Fix min step variable interpolation (#27505)

* Add missing dependency to lockfile

* Prometheus: Fix min step variable interpolation
This commit is contained in:
Zoltán Bedi
2020-09-10 20:31:53 +02:00
committed by GitHub
parent 9928f925ae
commit a7ac3f1419
3 changed files with 18 additions and 3 deletions

View File

@@ -351,7 +351,11 @@ export class PrometheusDatasource extends DataSourceApi<PromQuery, PromOptions>
templateSrv.replace(target.interval || options.interval, options.scopedVars)
);
// Scrape interval as specified for the query ("Min step") or otherwise taken from the datasource.
const scrapeInterval = rangeUtil.intervalToSeconds(target.interval || this.interval);
// Min step field can have template variables in it, make sure to replace it.
const scrapeInterval = target.interval
? rangeUtil.intervalToSeconds(templateSrv.replace(target.interval, options.scopedVars))
: rangeUtil.intervalToSeconds(this.interval);
const intervalFactor = target.intervalFactor || 1;
// Adjust the interval to take into account any specified minimum and interval factor plus Prometheus limits
const adjustedInterval = this.adjustInterval(interval, minInterval, range, intervalFactor);