|
@@ -168,12 +168,22 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
this.testDatasource = function() {
|
|
this.testDatasource = function() {
|
|
|
- timeSrv.setTime({ from: 'now-1m', to: 'now' });
|
|
|
|
|
- return this._get('/_stats').then(function() {
|
|
|
|
|
- return { status: "success", message: "Data source is working", title: "Success" };
|
|
|
|
|
- }, function(err) {
|
|
|
|
|
|
|
+ timeSrv.setTime({ from: 'now-1m', to: 'now' }, true);
|
|
|
|
|
+ // validate that the index exist and has date field
|
|
|
|
|
+ return this.getFields({type: 'date'}).then(function(dateFields) {
|
|
|
|
|
+ var timeField = _.find(dateFields, {text: this.timeField});
|
|
|
|
|
+ if (!timeField) {
|
|
|
|
|
+ return { status: "error", message: "No date field named " + this.timeField + ' found', title: "Error" };
|
|
|
|
|
+ }
|
|
|
|
|
+ return { status: "success", message: "Index OK. Time field name OK.", title: "Success" };
|
|
|
|
|
+ }.bind(this), function(err) {
|
|
|
|
|
+ console.log(err);
|
|
|
if (err.data && err.data.error) {
|
|
if (err.data && err.data.error) {
|
|
|
- return { status: "error", message: angular.toJson(err.data.error), title: "Error" };
|
|
|
|
|
|
|
+ var message = angular.toJson(err.data.error);
|
|
|
|
|
+ if (err.data.error.reason) {
|
|
|
|
|
+ message = err.data.error.reason;
|
|
|
|
|
+ }
|
|
|
|
|
+ return { status: "error", message: message, title: "Error" };
|
|
|
} else {
|
|
} else {
|
|
|
return { status: "error", message: err.status, title: "Error" };
|
|
return { status: "error", message: err.status, title: "Error" };
|
|
|
}
|
|
}
|