Browse Source

feat(influxdb): completed work on new influxdb query editor, now supports #2708, #2647, #2599

Torkel Ödegaard 10 years ago
parent
commit
1ab374008f

+ 3 - 0
CHANGELOG.md

@@ -19,6 +19,9 @@ it allows you to add queries of differnet data source types & instances to the s
 - [Issue #2457](https://github.com/grafana/grafana/issues/2457). Admin: admin page for all grafana organizations (list / edit view)
 - [Issue #1186](https://github.com/grafana/grafana/issues/1186). Time Picker: New option `today`, will set time range from midnight to now
 - [Issue #1186](https://github.com/grafana/grafana/issues/1186). Time Picker: New option `today`, will set time range from midnight to now
+- [Issue #2647](https://github.com/grafana/grafana/issues/2647). InfluxDB: You can now set group by time interval on each query
+- [Issue #2599](https://github.com/grafana/grafana/issues/2599). InfluxDB: Improved alias support, you can now use the `AS` clause for each select statement
+- [Issue #2708](https://github.com/grafana/grafana/issues/2708). InfluxDB: You can now set math expression for select clauses.
 
 **Fixes**
 - [Issue #2413](https://github.com/grafana/grafana/issues/2413). InfluxDB 0.9: Fix for handling empty series object in response from influxdb

+ 2 - 1
public/app/plugins/datasource/influxdb/partials/query.editor2.html

@@ -109,7 +109,8 @@
 				</li>
 				<li ng-if="groupBy.type === 'time'">
 					<span class="tight-form-item">time</span>
-					<metric-segment-model property="groupBy.interval" get-options="getGroupByTimeIntervals()" on-change="get_data()"></metric-segment>
+					<metric-segment-model property="groupBy.interval" get-options="getGroupByTimeIntervals()" on-change="get_data()">
+					</metric-segment>
 				</li>
 				<li ng-if="groupBy.type === 'tag'">
 					<metric-segment-model property="groupBy.key" get-options="getTagOptions()" on-change="get_data()"></metric-segment>

+ 8 - 1
public/app/plugins/datasource/influxdb/queryBuilder.js

@@ -6,6 +6,14 @@ function (_) {
 
   function InfluxQueryBuilder(target) {
     this.target = target;
+
+    if (target.groupByTags) {
+      target.groupBy = [{type: 'time', interval: 'auto'}];
+      for (var i in target.groupByTags) {
+        target.groupBy.push({type: 'tag', key: target.groupByTags[i]});
+      }
+      delete target.groupByTags;
+    }
   }
 
   function renderTagCondition (tag, index) {
@@ -84,7 +92,6 @@ function (_) {
     return query;
   };
 
-
   p._getGroupByTimeInterval = function(interval) {
     if (interval === 'auto') {
       return '$interval';

+ 1 - 5
public/app/plugins/datasource/influxdb/queryCtrl.js

@@ -16,10 +16,7 @@ function (angular, _, InfluxQueryBuilder) {
       var target = $scope.target;
       target.tags = target.tags || [];
       target.groupBy = target.groupBy || [{type: 'time', interval: 'auto'}];
-      target.fields = target.fields || [{
-        name: 'value',
-        func: target.function || 'mean'
-      }];
+      target.fields = target.fields || [{name: 'value', func: target.function || 'mean'}];
 
       $scope.queryBuilder = new InfluxQueryBuilder(target);
 
@@ -49,7 +46,6 @@ function (angular, _, InfluxQueryBuilder) {
       });
 
       $scope.fixTagSegments();
-
       $scope.removeTagFilterSegment = uiSegmentSrv.newSegment({fake: true, value: '-- remove tag filter --'});
     };
 

+ 2 - 1
public/test/specs/influx09-querybuilder-specs.js

@@ -68,7 +68,8 @@ define([
         });
 
         var query = builder.build();
-        expect(query).to.be('SELECT sum("tx_in") AS "tx_in", mean("tx_out") AS "tx_out" FROM "cpu" WHERE $timeFilter GROUP BY time($interval)');
+        expect(query).to.be('SELECT sum("tx_in") AS "tx_in", mean("tx_out") AS "tx_out" ' +
+                            'FROM "cpu" WHERE $timeFilter GROUP BY time($interval)');
       });
     });