Support time range to query dimension names/values
At present, dimensions are not scoped by time window, which makes dimension related queries to large databases timeout because it searches all of time instead of a time window specified on the grafana app. This commit aims to address issue by scoping the search to time range specified on the app. Change-Id: I13614595707697552119926273f06967b8d49b1d Story: 2006204 Task: 35789
This commit is contained in:
parent
7ce6b8773a
commit
5ff8dd5f6c
|
@ -51,6 +51,14 @@ function (angular, _, moment, sdk, dateMath, kbn) {
|
|||
self = this;
|
||||
}
|
||||
|
||||
MonascaDatasource.prototype.timeRange = function() {
|
||||
var timeRange = angular.element('grafana-app').injector().get('timeSrv').timeRange();
|
||||
return {
|
||||
start_time: this.translateTime(timeRange.from),
|
||||
end_time: this.translateTime(timeRange.to),
|
||||
};
|
||||
};
|
||||
|
||||
MonascaDatasource.prototype.query = function(options) {
|
||||
var datasource = this;
|
||||
var from = this.translateTime(options.range.from);
|
||||
|
@ -110,6 +118,8 @@ function (angular, _, moment, sdk, dateMath, kbn) {
|
|||
MonascaDatasource.prototype.dimensionNamesQuery = function(params) {
|
||||
var datasource = this;
|
||||
var url = this.url_version + '/metrics/dimensions/names';
|
||||
params = Object.assign(params, this.timeRange())
|
||||
console.log(params)
|
||||
return this._limitedMonascaRequest(url, params, false).then(function(data) {
|
||||
return datasource.convertDataList(data, 'dimension_name');
|
||||
}).catch(function(err) {throw err;});
|
||||
|
@ -118,6 +128,8 @@ function (angular, _, moment, sdk, dateMath, kbn) {
|
|||
MonascaDatasource.prototype.dimensionValuesQuery = function(params) {
|
||||
var datasource = this;
|
||||
var url = this.url_version + '/metrics/dimensions/names/values';
|
||||
params = Object.assign(params, this.timeRange())
|
||||
console.log(params)
|
||||
return this._limitedMonascaRequest(url, params, false).then(function(data) {
|
||||
return datasource.convertDataList(data, 'dimension_value');
|
||||
}).catch(function(err) {throw err;});
|
||||
|
|
Loading…
Reference in New Issue