Browse Source

Added test connection action to all data sources, Closes #1997

Torkel Ödegaard 10 years ago
parent
commit
50645cc36b

+ 9 - 0
public/app/features/org/datasourceEditCtrl.js

@@ -75,10 +75,19 @@ function (angular, config) {
           $scope.testing.title = 'Unknown';
           return;
         }
+
         return datasource.testDatasource().then(function(result) {
           $scope.testing.message = result.message;
           $scope.testing.status = result.status;
           $scope.testing.title = result.title;
+        }, function(err) {
+          if (err.statusText) {
+            $scope.testing.message = err.statusText;
+            $scope.testing.title = "HTTP Error";
+          } else {
+            $scope.testing.message = err.message;
+            $scope.testing.title = "Unknown error";
+          }
         });
       }).finally(function() {
         $scope.testing.done = true;

+ 0 - 10
public/app/plugins/datasource/graphite/datasource.js

@@ -199,16 +199,6 @@ function (angular, _, $, config, kbn, moment) {
     GraphiteDatasource.prototype.testDatasource = function() {
       return this.metricFindQuery('*').then(function () {
         return { status: "success", message: "Data source is working", title: "Success" };
-      }, function(err) {
-        var message, title;
-        if (err.statusText) {
-          message = err.statusText;
-          title = "HTTP Error";
-        } else {
-          message = err;
-          title = "Unknown error";
-        }
-        return { status: "error", message: message, title: title };
       });
     };
 

+ 0 - 10
public/app/plugins/datasource/influxdb/datasource.js

@@ -129,16 +129,6 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
     InfluxDatasource.prototype.testDatasource = function() {
       return this.metricFindQuery('SHOW MEASUREMENTS LIMIT 1').then(function () {
         return { status: "success", message: "Data source is working", title: "Success" };
-      }, function(err) {
-        var message, title;
-        if (err.statusText) {
-          message = err.statusText;
-          title = "HTTP Error";
-        } else {
-          message = err;
-          title = "Unknown error";
-        }
-        return { status: "error", message: message, title: title };
       });
     };
 

+ 6 - 0
public/app/plugins/datasource/influxdb_08/datasource.js

@@ -99,6 +99,12 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
       });
     };
 
+    InfluxDatasource.prototype.testDatasource = function() {
+      return this.metricFindQuery('list series').then(function () {
+        return { status: "success", message: "Data source is working", title: "Success" };
+      });
+    };
+
     InfluxDatasource.prototype.metricFindQuery = function (query) {
       var interpolated;
       try {

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

@@ -90,6 +90,12 @@ function (angular, _, kbn) {
       });
     };
 
+    OpenTSDBDatasource.prototype.testDatasource = function() {
+      return this.performSuggestQuery('cpu', 'metrics').then(function () {
+        return { status: "success", message: "Data source is working", title: "Success" };
+      });
+    };
+
     function transformMetricData(md, groupByTags, options) {
       var metricLabel = createMetricLabel(md, options, groupByTags);
       var dps = [];