diff --git a/src/app/controllers/influxTargetCtrl.js b/src/app/controllers/influxTargetCtrl.js index 7ad82ae6807..e481970c254 100644 --- a/src/app/controllers/influxTargetCtrl.js +++ b/src/app/controllers/influxTargetCtrl.js @@ -18,6 +18,7 @@ function (angular) { $scope.rawQuery = false; $scope.functions = ['count', 'mean', 'sum', 'min', 'max', 'mode', 'distinct', 'median', 'derivative', 'stddev', 'first', 'last']; + $scope.operators = ['=', '=~', '>', '<', '!~', '<>']; $scope.oldSeries = $scope.target.series; $scope.$on('typeahead-updated', function(){ $timeout($scope.get_data); diff --git a/src/app/partials/influxdb/editor.html b/src/app/partials/influxdb/editor.html index 32f7f5c2582..0c7b077bc19 100644 --- a/src/app/partials/influxdb/editor.html +++ b/src/app/partials/influxdb/editor.html @@ -51,13 +51,25 @@ data-min-length=0 data-items=100 ng-blur="get_data()"> +
  • + label +
  • + +
  • + +
  • from series
  • function
  • -
  • -
  • - +
  • + + + +
  • +
  • + + + + +
  • group by time
  • diff --git a/src/app/services/influxdb/influxdbDatasource.js b/src/app/services/influxdb/influxdbDatasource.js index c12a2a4c238..d443d3ebb40 100644 --- a/src/app/services/influxdb/influxdbDatasource.js +++ b/src/app/services/influxdb/influxdbDatasource.js @@ -60,25 +60,29 @@ function (angular, _, kbn) { } query = queryElements.join(" "); - } else { - var template = "select [[func]]([[column]]) as [[column]]_[[func]] from [[series]] where [[timeFilter]]" + - " group by time([[interval]]) order asc"; + var template = "select [[func]]([[column]]) as [[column]]_[[func]] from [[series]] " + + "where [[timeFilter]] [[condition_add]] [[condition_key]] [[condition_op]] [[condition_value]] " + + "group by time([[interval]]) order asc"; var templateData = { series: target.series, column: target.column, func: target.function, timeFilter: timeFilter, - interval: target.interval || options.interval + interval: target.interval || options.interval, + condition_add: target.condiction_filter ? target.condition_add : '', + condition_key: target.condiction_filter ? target.condition_key : '', + condition_op: target.condiction_filter ? target.condition_op : '', + condition_value: target.condiction_filter ? target.condition_value: '' }; query = _.template(template, templateData, this.templateSettings); target.query = query; } - return this.doInfluxRequest(query).then(handleInfluxQueryResponse); + return this.doInfluxRequest(query, target.label).then(handleInfluxQueryResponse); }, this); @@ -117,7 +121,7 @@ function (angular, _, kbn) { }); } - InfluxDatasource.prototype.doInfluxRequest = function(query) { + InfluxDatasource.prototype.doInfluxRequest = function(query, label) { var _this = this; var deferred = $q.defer(); @@ -138,6 +142,7 @@ function (angular, _, kbn) { }; return $http(options).success(function (data) { + data.label = label; deferred.resolve(data); }); }, 10); @@ -156,9 +161,7 @@ function (angular, _, kbn) { return; } - console.log("series:"+series.name + ": "+series.points.length + " points"); - - var target = series.name + "." + column; + var target = data.label || series.name + "." + column; var datapoints = []; for(var i = 0; i < series.points.length; i++) {