Kaynağa Gözat

Instead of hard-coding the OpenTsdb aggregators list, pull the supported
aggregators from the datasource directly.

Mike Kobyakov 10 yıl önce
ebeveyn
işleme
e395211654

+ 14 - 0
public/app/plugins/datasource/opentsdb/datasource.js

@@ -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 = [];

+ 6 - 0
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';
       }