diff --git a/public/app/plugins/datasource/influxdb/funcEditor.js b/public/app/plugins/datasource/influxdb/funcEditor.js
index 7631363fa122..ae4248cf2a6c 100644
--- a/public/app/plugins/datasource/influxdb/funcEditor.js
+++ b/public/app/plugins/datasource/influxdb/funcEditor.js
@@ -124,7 +124,7 @@ function (angular, _, $) {
function addElementsAndCompile() {
$funcLink.appendTo(elem);
- var $paramLink = $('value');
+ var $paramLink = $('' + $scope.field.name + '');
var $input = $(paramTemplate);
$paramLink.appendTo(elem);
diff --git a/public/app/plugins/datasource/influxdb/partials/query.editor.html b/public/app/plugins/datasource/influxdb/partials/query.editor.html
index 216f099d1255..d63e68538318 100644
--- a/public/app/plugins/datasource/influxdb/partials/query.editor.html
+++ b/public/app/plugins/datasource/influxdb/partials/query.editor.html
@@ -66,9 +66,12 @@
SELECT
-
+
+
+
+
diff --git a/public/app/plugins/datasource/influxdb/queryCtrl.js b/public/app/plugins/datasource/influxdb/queryCtrl.js
index e28c6bc034da..a57737cba938 100644
--- a/public/app/plugins/datasource/influxdb/queryCtrl.js
+++ b/public/app/plugins/datasource/influxdb/queryCtrl.js
@@ -27,6 +27,8 @@ function (angular, _, InfluxQueryBuilder) {
$scope.measurementSegment = new MetricSegment(target.measurement);
}
+ $scope.addFieldSegment = MetricSegment.newPlusButton();
+
$scope.tagSegments = [];
_.each(target.tags, function(tag) {
if (tag.condition) {
@@ -92,7 +94,11 @@ function (angular, _, InfluxQueryBuilder) {
var fieldsQuery = $scope.queryBuilder.buildExploreQuery('FIELDS');
return $scope.datasource.metricFindQuery(fieldsQuery)
.then(function(results) {
- return _.pluck(results, 'text');
+ var values = _.pluck(results, 'text');
+ if ($scope.target.fields.length > 1) {
+ values.splice(0, 0, "-- remove from select --");
+ }
+ return values;
});
};
@@ -161,6 +167,25 @@ function (angular, _, InfluxQueryBuilder) {
.then(null, $scope.handleQueryError);
};
+ $scope.getFieldSegments = function() {
+ var fieldsQuery = $scope.queryBuilder.buildExploreQuery('FIELDS');
+ return $scope.datasource.metricFindQuery(fieldsQuery)
+ .then($scope.transformToSegments)
+ .then(null, $scope.handleQueryError);
+ };
+
+ $scope.addField = function() {
+ $scope.target.fields.push({name: $scope.addFieldSegment.value, func: 'mean'});
+ _.extend($scope.addFieldSegment, MetricSegment.newPlusButton());
+ };
+
+ $scope.fieldChanged = function(field) {
+ if (field.name === '-- remove from select --') {
+ $scope.target.fields = _.without($scope.target.fields, field);
+ }
+ $scope.get_data();
+ };
+
$scope.getGroupByTagSegments = function(segment) {
var query = $scope.queryBuilder.buildExploreQuery('TAG_KEYS');