Instead of hard-coding the OpenTsdb aggregators list, pull the supported

aggregators from the datasource directly.
This commit is contained in:
Mike Kobyakov 2015-03-25 14:32:26 -07:00
parent 9f6a348851
commit e395211654
2 changed files with 20 additions and 0 deletions

View File

@ -90,6 +90,20 @@ function (angular, _, kbn) {
});
};
OpenTSDBDatasource.prototype.performAggregatorsQuery = function() {
var options = {
method: 'GET',
url: this.url + '/api/aggregators'
};
return $http(options).then(function(result) {
if (result.data instanceof Array) {
return result.data.sort();
} else {
return result.data;
}
});
};
function transformMetricData(md, groupByTags, options) {
var metricLabel = createMetricLabel(md, options, groupByTags);
var dps = [];

View File

@ -14,6 +14,12 @@ function (angular, _, kbn) {
$scope.target.errors = validateTarget($scope.target);
$scope.aggregators = ['avg', 'sum', 'min', 'max', 'dev', 'zimsum', 'mimmin', 'mimmax'];
$scope.datasource.performAggregatorsQuery().then(function(result) {
if (result) {
$scope.aggregators = result;
}
});
if (!$scope.target.aggregator) {
$scope.target.aggregator = 'sum';
}