diff --git a/public/app/plugins/datasource/opentsdb/datasource.js b/public/app/plugins/datasource/opentsdb/datasource.js index c4fd7dc5f77..fb969551195 100644 --- a/public/app/plugins/datasource/opentsdb/datasource.js +++ b/public/app/plugins/datasource/opentsdb/datasource.js @@ -175,6 +175,16 @@ function (angular, _, dateMath) { }); }; + OpenTSDBDatasource.prototype.performAggregatorsQuery = function() { + return this._get('/api/aggregators', {}).then(function(result) { + if (result.data instanceof Array) { + return result.data.sort(); + } else { + return result.data; + } + }); + }; + function transformMetricData(md, groupByTags, target, options) { var metricLabel = createMetricLabel(md, target, groupByTags, options); var dps = []; diff --git a/public/app/plugins/datasource/opentsdb/queryCtrl.js b/public/app/plugins/datasource/opentsdb/queryCtrl.js index dd2e00aca6f..ed5b842d259 100644 --- a/public/app/plugins/datasource/opentsdb/queryCtrl.js +++ b/public/app/plugins/datasource/opentsdb/queryCtrl.js @@ -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'; }