Browse Source

use SHOW RETENTIONS to test influxdb connection (#9824)

Dan Cech 8 năm trước cách đây
mục cha
commit
5b38c230db
1 tập tin đã thay đổi với 7 bổ sung4 xóa
  1. 7 4
      public/app/plugins/datasource/influxdb/datasource.ts

+ 7 - 4
public/app/plugins/datasource/influxdb/datasource.ts

@@ -190,10 +190,13 @@ export default class InfluxDatasource {
   }
 
   testDatasource() {
-    return this.metricFindQuery('SHOW DATABASES').then(res => {
-      let found = _.find(res, {text: this.database});
-      if (!found) {
-        return { status: "error", message: "Could not find the specified database name." };
+    var queryBuilder = new InfluxQueryBuilder({measurement: '', tags: []}, this.database);
+    var query = queryBuilder.buildExploreQuery('RETENTION POLICIES');
+
+    return this._seriesQuery(query).then(res => {
+      let error = _.get(res, 'results[0].error');
+      if (error) {
+        return { status: "error", message: error };
       }
       return { status: "success", message: "Data source is working" };
     }).catch(err => {