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

This commit is contained in:
Torkel Ödegaard
2015-06-01 14:16:59 +02:00
parent afede880e6
commit 50645cc36b
5 changed files with 21 additions and 20 deletions

View File

@@ -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;

View File

@@ -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 };
});
};

View File

@@ -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 };
});
};

View File

@@ -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 {

View File

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