mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Create cacheKey at top-level
Responsibility is now to pass the cacheKey through to `datasourceRequest` in each datasources' implementation of `query`.
This commit is contained in:
parent
18f9f6c159
commit
bc7c2cd3f5
@ -182,6 +182,10 @@ class MetricsPanelCtrl extends PanelCtrl {
|
||||
cacheTimeout: this.panel.cacheTimeout
|
||||
};
|
||||
|
||||
metricsQuery.targets.forEach(function(target) {
|
||||
target.cacheKey = target.expr + target.refId + metricsQuery.panelId;
|
||||
});
|
||||
|
||||
return datasource.query(metricsQuery);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
|
||||
var options: any = {
|
||||
url: this.url + url,
|
||||
method: method,
|
||||
cacheKey: cacheKey
|
||||
cacheKey: cacheKey,
|
||||
};
|
||||
|
||||
if (this.basicAuth || this.withCredentials) {
|
||||
@ -76,6 +76,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
|
||||
|
||||
var query: any = {};
|
||||
query.expr = templateSrv.replace(target.expr, options.scopedVars, self.interpolateQueryExpr);
|
||||
query.cacheKey = target.cacheKey;
|
||||
|
||||
var interval = target.interval || options.interval;
|
||||
var intervalFactor = target.intervalFactor || 1;
|
||||
@ -123,7 +124,7 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
|
||||
|
||||
this.performTimeSeriesQuery = function(query, start, end) {
|
||||
var url = '/api/v1/query_range?query=' + encodeURIComponent(query.expr) + '&start=' + start + '&end=' + end + '&step=' + query.step;
|
||||
return this._request('GET', url, query.expr.toString());
|
||||
return this._request('GET', url, query.cacheKey);
|
||||
};
|
||||
|
||||
this.performSuggestQuery = function(query) {
|
||||
|
Loading…
Reference in New Issue
Block a user