Sfoglia il codice sorgente

Support timeFilter in templating for InfluxDB

After support for queries in template variables was added to InfluxDB,
it can be necessary to added dymanic time constraints. This can now be
done changing the variable refresh to "On Time Range Changed" for
InfluxDB
Kim Christensen 7 anni fa
parent
commit
a2574ac068
1 ha cambiato i file con 5 aggiunte e 0 eliminazioni
  1. 5 0
      public/app/plugins/datasource/influxdb/datasource.ts

+ 5 - 0
public/app/plugins/datasource/influxdb/datasource.ts

@@ -187,6 +187,11 @@ export default class InfluxDatasource {
       return this.$q.when({ results: [] });
       return this.$q.when({ results: [] });
     }
     }
 
 
+    if (options && options.range) {
+      var timeFilter = this.getTimeFilter({ rangeRaw: options.range });
+      query = query.replace('$timeFilter', timeFilter);
+    }
+
     return this._influxRequest('GET', '/query', { q: query, epoch: 'ms' }, options);
     return this._influxRequest('GET', '/query', { q: query, epoch: 'ms' }, options);
   }
   }