From 073106437562332d0958e0aef286e30ea1275737 Mon Sep 17 00:00:00 2001 From: Carl Bergquist Date: Tue, 8 Dec 2015 12:04:42 +0100 Subject: [PATCH 01/27] adds support for moving avg support in es queries --- .../datasource/elasticsearch/query_builder.js | 25 ++++++++++++++++--- .../specs/query_builder_specs.ts | 24 ++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/query_builder.js b/public/app/plugins/datasource/elasticsearch/query_builder.js index d736966285c..e388ad63fdb 100644 --- a/public/app/plugins/datasource/elasticsearch/query_builder.js +++ b/public/app/plugins/datasource/elasticsearch/query_builder.js @@ -175,8 +175,28 @@ function () { } var aggField = {}; - aggField[metric.type] = metricAgg; - nestedAggs.aggs[metric.id] = aggField; + if (metric.type === 'moving_avg') { + var pipeAgg = ''; + for(var aggname in nestedAggs.aggs) { + var agg = nestedAggs.aggs[aggname]; + for(prop in agg) { + if (agg.hasOwnProperty(prop) && agg[prop] !== null) { + if (metric.field === prop) { + pipeAgg = aggname; + break; + } + } + } + } + + if (pipeAgg !== '') { + aggField[metric.type] = { buckets_path: pipeAgg }; + nestedAggs.aggs[metric.id] = aggField; + } + } else { + aggField[metric.type] = metricAgg; + nestedAggs.aggs[metric.id] = aggField; + } } return query; @@ -217,5 +237,4 @@ function () { }; return ElasticQueryBuilder; - }); diff --git a/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts b/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts index 3cfdf61620e..931d9a3613e 100644 --- a/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts +++ b/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts @@ -155,4 +155,28 @@ describe('ElasticQueryBuilder', function() { expect(query.size).to.be(500); }); + it('with moving average', function() { + var query = builder.build({ + metrics: [ + { + id: '1', + type: 'sum', + field: '@value', + }, + { + id: '2', + type: 'moving_avg', + field: 'sum' + } + ], + bucketAggs: [ + {type: 'date_histogram', field: '@timestamp', id: '3'} + ], + }); + + var firstLevel = query.aggs["3"]; + expect(firstLevel.aggs["2"]).not.to.be(undefined); + expect(firstLevel.aggs["2"].moving_avg).not.to.be(undefined); + expect(firstLevel.aggs["2"].moving_avg.buckets_path).to.be("1"); + }); }); From 8ad10149abddf279a07e0c337d251d6bfabe477a Mon Sep 17 00:00:00 2001 From: Carl Bergquist Date: Tue, 8 Dec 2015 12:06:36 +0100 Subject: [PATCH 02/27] adds basic support for moving avg in es queries --- .../datasource/elasticsearch/metric_agg.js | 17 +++++++++++++++++ .../elasticsearch/partials/metricAgg.html | 5 ++++- .../datasource/elasticsearch/query_def.js | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/elasticsearch/metric_agg.js b/public/app/plugins/datasource/elasticsearch/metric_agg.js index c4e04dad325..2073fbc3a55 100644 --- a/public/app/plugins/datasource/elasticsearch/metric_agg.js +++ b/public/app/plugins/datasource/elasticsearch/metric_agg.js @@ -78,6 +78,23 @@ function (angular, _, queryDef) { return $scope.getFields({$fieldType: 'number'}); }; + $scope.getMetrics = function() { + console.log($scope.target.metrics); + + var mets = _.filter($scope.target.metrics, function(x) { + return x.type !== 'moving_avg'; + }); + + mets = _.map(mets, function(m) { + return { text: m.type, type: m.id }; + }); + + console.log(mets); + + return $q.when(mets) + .then(uiSegmentSrv.transformToSegments(false)); + }; + $scope.addMetricAgg = function() { var addIndex = metricAggs.length; diff --git a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html index 65030af5655..09f48e487eb 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html @@ -7,7 +7,10 @@
  • - + +
  • +
  • +
  • {{settingsLinkText}} diff --git a/public/app/plugins/datasource/elasticsearch/query_def.js b/public/app/plugins/datasource/elasticsearch/query_def.js index baab2378e9f..1f7d352a2cc 100644 --- a/public/app/plugins/datasource/elasticsearch/query_def.js +++ b/public/app/plugins/datasource/elasticsearch/query_def.js @@ -13,6 +13,7 @@ function (_) { {text: "Min", value: 'min', requiresField: true}, {text: "Extended Stats", value: 'extended_stats', requiresField: true}, {text: "Percentiles", value: 'percentiles', requiresField: true}, + {text: "Moving Avg", value: 'moving_avg', requiresField: false, requiresBucketsPath: true}, {text: "Unique Count", value: "cardinality", requiresField: true}, {text: "Raw Document", value: "raw_document", requiresField: false} ], From dd7a13930f517b548e70eee8cea9148d59d8b7c5 Mon Sep 17 00:00:00 2001 From: Carl Bergquist Date: Tue, 8 Dec 2015 12:07:56 +0100 Subject: [PATCH 03/27] adds null check for response parser --- .../elasticsearch/elastic_response.js | 8 +++- .../datasource/elasticsearch/metric_agg.js | 18 +++------ .../elasticsearch/partials/metricAgg.html | 2 +- .../datasource/elasticsearch/query_builder.js | 40 ++++++++----------- .../datasource/elasticsearch/query_def.js | 2 +- .../specs/query_builder_specs.ts | 11 ++--- 6 files changed, 34 insertions(+), 47 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/elastic_response.js b/public/app/plugins/datasource/elasticsearch/elastic_response.js index 73050ce7f2b..a7c8e6d14bf 100644 --- a/public/app/plugins/datasource/elasticsearch/elastic_response.js +++ b/public/app/plugins/datasource/elasticsearch/elastic_response.js @@ -76,8 +76,12 @@ function (_, queryDef) { newSeries = { datapoints: [], metric: metric.type, field: metric.field, props: props}; for (i = 0; i < esAgg.buckets.length; i++) { bucket = esAgg.buckets[i]; - value = bucket[metric.id].value; - newSeries.datapoints.push([value, bucket.key]); + + value = bucket[metric.id]; + if (value !== undefined) { + newSeries.datapoints.push([value.value, bucket.key]); + } + } seriesList.push(newSeries); break; diff --git a/public/app/plugins/datasource/elasticsearch/metric_agg.js b/public/app/plugins/datasource/elasticsearch/metric_agg.js index 2073fbc3a55..ab1afa6a017 100644 --- a/public/app/plugins/datasource/elasticsearch/metric_agg.js +++ b/public/app/plugins/datasource/elasticsearch/metric_agg.js @@ -35,6 +35,10 @@ function (angular, _, queryDef) { } switch($scope.agg.type) { + case 'moving_avg': { + $scope.agg.aggregation = $scope.agg.aggregation || 'sum'; + break; + } case 'percentiles': { $scope.agg.settings.percents = $scope.agg.settings.percents || [25,50,75,95,99]; $scope.settingsLinkText = 'values: ' + $scope.agg.settings.percents.join(','); @@ -79,19 +83,9 @@ function (angular, _, queryDef) { }; $scope.getMetrics = function() { - console.log($scope.target.metrics); + var aggs = [{ text: 'Sum', type: 'sum'}, { text: 'Average', type: 'avg'}]; - var mets = _.filter($scope.target.metrics, function(x) { - return x.type !== 'moving_avg'; - }); - - mets = _.map(mets, function(m) { - return { text: m.type, type: m.id }; - }); - - console.log(mets); - - return $q.when(mets) + return $q.when(aggs) .then(uiSegmentSrv.transformToSegments(false)); }; diff --git a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html index 09f48e487eb..fd487d52d3b 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html @@ -10,7 +10,7 @@
  • - +
  • {{settingsLinkText}} diff --git a/public/app/plugins/datasource/elasticsearch/query_builder.js b/public/app/plugins/datasource/elasticsearch/query_builder.js index e388ad63fdb..5d1492640dd 100644 --- a/public/app/plugins/datasource/elasticsearch/query_builder.js +++ b/public/app/plugins/datasource/elasticsearch/query_builder.js @@ -167,36 +167,28 @@ function () { continue; } - var metricAgg = {field: metric.field}; + var aggField = {}; + var metricAgg = null; + if (metric.type === 'moving_avg') { + var subBucket = metric.id + "_mavg"; + + var af = {}; + af[metric.aggregation] = {field: metric.field}; + nestedAggs.aggs[subBucket] = af; + + metricAgg = { buckets_path: subBucket }; + } else { + metricAgg = {field: metric.field}; + } + for (var prop in metric.settings) { if (metric.settings.hasOwnProperty(prop) && metric.settings[prop] !== null) { metricAgg[prop] = metric.settings[prop]; } } - var aggField = {}; - if (metric.type === 'moving_avg') { - var pipeAgg = ''; - for(var aggname in nestedAggs.aggs) { - var agg = nestedAggs.aggs[aggname]; - for(prop in agg) { - if (agg.hasOwnProperty(prop) && agg[prop] !== null) { - if (metric.field === prop) { - pipeAgg = aggname; - break; - } - } - } - } - - if (pipeAgg !== '') { - aggField[metric.type] = { buckets_path: pipeAgg }; - nestedAggs.aggs[metric.id] = aggField; - } - } else { - aggField[metric.type] = metricAgg; - nestedAggs.aggs[metric.id] = aggField; - } + aggField[metric.type] = metricAgg; + nestedAggs.aggs[metric.id] = aggField; } return query; diff --git a/public/app/plugins/datasource/elasticsearch/query_def.js b/public/app/plugins/datasource/elasticsearch/query_def.js index 1f7d352a2cc..ec5141c1e8d 100644 --- a/public/app/plugins/datasource/elasticsearch/query_def.js +++ b/public/app/plugins/datasource/elasticsearch/query_def.js @@ -13,7 +13,7 @@ function (_) { {text: "Min", value: 'min', requiresField: true}, {text: "Extended Stats", value: 'extended_stats', requiresField: true}, {text: "Percentiles", value: 'percentiles', requiresField: true}, - {text: "Moving Avg", value: 'moving_avg', requiresField: false, requiresBucketsPath: true}, + {text: "Moving Avg", value: 'moving_avg', requiresField: true, requiresBucketsPath: true}, {text: "Unique Count", value: "cardinality", requiresField: true}, {text: "Raw Document", value: "raw_document", requiresField: false} ], diff --git a/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts b/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts index 931d9a3613e..0bda6ab73b1 100644 --- a/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts +++ b/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts @@ -158,15 +158,11 @@ describe('ElasticQueryBuilder', function() { it('with moving average', function() { var query = builder.build({ metrics: [ - { - id: '1', - type: 'sum', - field: '@value', - }, { id: '2', type: 'moving_avg', - field: 'sum' + field: '@value', + aggregation: 'sum' } ], bucketAggs: [ @@ -175,8 +171,9 @@ describe('ElasticQueryBuilder', function() { }); var firstLevel = query.aggs["3"]; + console.log(JSON.stringify(query)); expect(firstLevel.aggs["2"]).not.to.be(undefined); expect(firstLevel.aggs["2"].moving_avg).not.to.be(undefined); - expect(firstLevel.aggs["2"].moving_avg.buckets_path).to.be("1"); + expect(firstLevel.aggs["2"].moving_avg.buckets_path).to.be("99"); }); }); From b4763290de1f8ab88165fe13cb68550797d3d09b Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Wed, 9 Dec 2015 08:31:01 +0100 Subject: [PATCH 04/27] move target extraction logic to query def --- .../datasource/elasticsearch/query_def.js | 14 +++++- .../elasticsearch/specs/query_def_specs.ts | 48 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts diff --git a/public/app/plugins/datasource/elasticsearch/query_def.js b/public/app/plugins/datasource/elasticsearch/query_def.js index ec5141c1e8d..94401de778b 100644 --- a/public/app/plugins/datasource/elasticsearch/query_def.js +++ b/public/app/plugins/datasource/elasticsearch/query_def.js @@ -13,7 +13,7 @@ function (_) { {text: "Min", value: 'min', requiresField: true}, {text: "Extended Stats", value: 'extended_stats', requiresField: true}, {text: "Percentiles", value: 'percentiles', requiresField: true}, - {text: "Moving Avg", value: 'moving_avg', requiresField: true, requiresBucketsPath: true}, + {text: "Moving Avg", value: 'moving_avg', requiresField: false, requiresBucketsPath: true}, {text: "Unique Count", value: "cardinality", requiresField: true}, {text: "Raw Document", value: "raw_document", requiresField: false} ], @@ -67,6 +67,18 @@ function (_) { {text: '1d', value: '1d'}, ], + getMovingAverageSourceOptions: function(targets) { + var self = this; + var result = []; + _.each(targets.metrics, function(metric) { + if (metric.type !== 'moving_avg') { + result.push({text: self.describeMetric(metric), value: metric.id }); + } + }); + + return result; + }, + getOrderByOptions: function(target) { var self = this; var metricRefs = []; diff --git a/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts b/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts new file mode 100644 index 00000000000..18d22f794d5 --- /dev/null +++ b/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts @@ -0,0 +1,48 @@ +/// +/// + +import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common'; + +declare var helpers: any; +declare var QueryDef: any; + +describe('ElasticQueryDef', function() { + + describe('with zero targets', function() { + var response = QueryDef.getMovingAverageSourceOptions([]); + + it('should return zero', function() { + expect(response.length).to.be(0); + }); + }); + + describe('with count and sum targets', function() { + var targets = { + metrics: [ + { type: 'count', field: '@value' }, + { type: 'sum', field: '@value' } + ] + }; + + var response = QueryDef.getMovingAverageSourceOptions(targets); + + it('should return zero', function() { + expect(response.length).to.be(2); + }); + }); + + describe('with count and moving average targets', function() { + var targets = { + metrics: [ + { type: 'count', field: '@value' }, + { type: 'moving_avg', field: '@value' } + ] + }; + + var response = QueryDef.getMovingAverageSourceOptions(targets); + + it('should return zero', function() { + expect(response.length).to.be(1); + }); + }); +}); From ad79df9b74baafb7782d92ffcc261fae2004e4e4 Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Wed, 9 Dec 2015 09:04:48 +0100 Subject: [PATCH 05/27] changes implementation direction moving average will now be based on another metric instead of having moving average on itself --- .../datasource/elasticsearch/metric_agg.js | 21 ++++++++++++------- .../elasticsearch/partials/metricAgg.html | 14 ++++++++++--- .../datasource/elasticsearch/query_builder.js | 9 ++------ .../datasource/elasticsearch/query_def.js | 2 +- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/metric_agg.js b/public/app/plugins/datasource/elasticsearch/metric_agg.js index ab1afa6a017..6e149e91384 100644 --- a/public/app/plugins/datasource/elasticsearch/metric_agg.js +++ b/public/app/plugins/datasource/elasticsearch/metric_agg.js @@ -13,6 +13,7 @@ function (angular, _, queryDef) { $scope.metricAggTypes = queryDef.metricAggTypes; $scope.extendedStats = queryDef.extendedStats; + $scope.mavgSourceOptions = []; $scope.init = function() { $scope.agg = metricAggs[$scope.index]; @@ -22,6 +23,7 @@ function (angular, _, queryDef) { $rootScope.onAppEvent('elastic-query-updated', function() { $scope.index = _.indexOf(metricAggs, $scope.agg); $scope.validateModel(); + $scope.updateMovingAverageOptions(); }, $scope); $scope.validateModel = function() { @@ -36,7 +38,8 @@ function (angular, _, queryDef) { switch($scope.agg.type) { case 'moving_avg': { - $scope.agg.aggregation = $scope.agg.aggregation || 'sum'; + $scope.agg.mavgSource = $scope.agg.mavgSource || ''; + $scope.settingsLinkText = 'Moving average options'; break; } case 'percentiles': { @@ -69,6 +72,11 @@ function (angular, _, queryDef) { $scope.toggleOptions = function() { $scope.showOptions = !$scope.showOptions; + $scope.updateMovingAverageOptions(); + }; + + $scope.onChangeInternal = function() { + $scope.onChange(); }; $scope.onTypeChange = function() { @@ -82,13 +90,6 @@ function (angular, _, queryDef) { return $scope.getFields({$fieldType: 'number'}); }; - $scope.getMetrics = function() { - var aggs = [{ text: 'Sum', type: 'sum'}, { text: 'Average', type: 'avg'}]; - - return $q.when(aggs) - .then(uiSegmentSrv.transformToSegments(false)); - }; - $scope.addMetricAgg = function() { var addIndex = metricAggs.length; @@ -100,6 +101,10 @@ function (angular, _, queryDef) { $scope.onChange(); }; + $scope.updateMovingAverageOptions = function() { + $scope.mvagSourceOptions = queryDef.getMovingAverageSourceOptions($scope.target); + }; + $scope.removeMetricAgg = function() { metricAggs.splice($scope.index, 1); $scope.onChange(); diff --git a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html index fd487d52d3b..2e34b28612d 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html @@ -9,9 +9,6 @@
  • -
  • - -
  • {{settingsLinkText}}
  • @@ -30,6 +27,17 @@
    +
    +
      +
    • + Based on +
    • +
    • + +
    • +
    +
    +
    • diff --git a/public/app/plugins/datasource/elasticsearch/query_builder.js b/public/app/plugins/datasource/elasticsearch/query_builder.js index 5d1492640dd..5cd7d1dae50 100644 --- a/public/app/plugins/datasource/elasticsearch/query_builder.js +++ b/public/app/plugins/datasource/elasticsearch/query_builder.js @@ -169,14 +169,9 @@ function () { var aggField = {}; var metricAgg = null; + if (metric.type === 'moving_avg') { - var subBucket = metric.id + "_mavg"; - - var af = {}; - af[metric.aggregation] = {field: metric.field}; - nestedAggs.aggs[subBucket] = af; - - metricAgg = { buckets_path: subBucket }; + metricAgg = {buckets_path: "1"}; } else { metricAgg = {field: metric.field}; } diff --git a/public/app/plugins/datasource/elasticsearch/query_def.js b/public/app/plugins/datasource/elasticsearch/query_def.js index 94401de778b..865c74753b3 100644 --- a/public/app/plugins/datasource/elasticsearch/query_def.js +++ b/public/app/plugins/datasource/elasticsearch/query_def.js @@ -13,7 +13,7 @@ function (_) { {text: "Min", value: 'min', requiresField: true}, {text: "Extended Stats", value: 'extended_stats', requiresField: true}, {text: "Percentiles", value: 'percentiles', requiresField: true}, - {text: "Moving Avg", value: 'moving_avg', requiresField: false, requiresBucketsPath: true}, + {text: "Moving Avg", value: 'moving_avg', requiresField: false }, {text: "Unique Count", value: "cardinality", requiresField: true}, {text: "Raw Document", value: "raw_document", requiresField: false} ], From 78c6ce842e57c728550d7e96f528f4ee4723090c Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Wed, 9 Dec 2015 09:10:50 +0100 Subject: [PATCH 06/27] revert elastic response parser --- .../plugins/datasource/elasticsearch/elastic_response.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/elastic_response.js b/public/app/plugins/datasource/elasticsearch/elastic_response.js index a7c8e6d14bf..73050ce7f2b 100644 --- a/public/app/plugins/datasource/elasticsearch/elastic_response.js +++ b/public/app/plugins/datasource/elasticsearch/elastic_response.js @@ -76,12 +76,8 @@ function (_, queryDef) { newSeries = { datapoints: [], metric: metric.type, field: metric.field, props: props}; for (i = 0; i < esAgg.buckets.length; i++) { bucket = esAgg.buckets[i]; - - value = bucket[metric.id]; - if (value !== undefined) { - newSeries.datapoints.push([value.value, bucket.key]); - } - + value = bucket[metric.id].value; + newSeries.datapoints.push([value, bucket.key]); } seriesList.push(newSeries); break; From f51d74fa6803df64b8419d36b63ced5b913855f5 Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Wed, 9 Dec 2015 09:47:56 +0100 Subject: [PATCH 07/27] change the way options are added --- .../datasource/elasticsearch/elastic_response.js | 8 ++++++-- .../plugins/datasource/elasticsearch/metric_agg.js | 13 ++++++------- .../elasticsearch/partials/metricAgg.html | 2 +- .../plugins/datasource/elasticsearch/query_def.js | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/elastic_response.js b/public/app/plugins/datasource/elasticsearch/elastic_response.js index 73050ce7f2b..a7c8e6d14bf 100644 --- a/public/app/plugins/datasource/elasticsearch/elastic_response.js +++ b/public/app/plugins/datasource/elasticsearch/elastic_response.js @@ -76,8 +76,12 @@ function (_, queryDef) { newSeries = { datapoints: [], metric: metric.type, field: metric.field, props: props}; for (i = 0; i < esAgg.buckets.length; i++) { bucket = esAgg.buckets[i]; - value = bucket[metric.id].value; - newSeries.datapoints.push([value, bucket.key]); + + value = bucket[metric.id]; + if (value !== undefined) { + newSeries.datapoints.push([value.value, bucket.key]); + } + } seriesList.push(newSeries); break; diff --git a/public/app/plugins/datasource/elasticsearch/metric_agg.js b/public/app/plugins/datasource/elasticsearch/metric_agg.js index 6e149e91384..157ee95a6c4 100644 --- a/public/app/plugins/datasource/elasticsearch/metric_agg.js +++ b/public/app/plugins/datasource/elasticsearch/metric_agg.js @@ -13,7 +13,6 @@ function (angular, _, queryDef) { $scope.metricAggTypes = queryDef.metricAggTypes; $scope.extendedStats = queryDef.extendedStats; - $scope.mavgSourceOptions = []; $scope.init = function() { $scope.agg = metricAggs[$scope.index]; @@ -23,7 +22,6 @@ function (angular, _, queryDef) { $rootScope.onAppEvent('elastic-query-updated', function() { $scope.index = _.indexOf(metricAggs, $scope.agg); $scope.validateModel(); - $scope.updateMovingAverageOptions(); }, $scope); $scope.validateModel = function() { @@ -38,7 +36,7 @@ function (angular, _, queryDef) { switch($scope.agg.type) { case 'moving_avg': { - $scope.agg.mavgSource = $scope.agg.mavgSource || ''; + $scope.agg.mavgSource = $scope.agg.mavgSource || 'Basec on metric'; $scope.settingsLinkText = 'Moving average options'; break; } @@ -90,6 +88,11 @@ function (angular, _, queryDef) { return $scope.getFields({$fieldType: 'number'}); }; + $scope.mavgSourceOptions = function() { + return $q.when(queryDef.getMovingAverageSourceOptions($scope.target)) + .then(uiSegmentSrv.transformToSegments(false)); + }; + $scope.addMetricAgg = function() { var addIndex = metricAggs.length; @@ -101,10 +104,6 @@ function (angular, _, queryDef) { $scope.onChange(); }; - $scope.updateMovingAverageOptions = function() { - $scope.mvagSourceOptions = queryDef.getMovingAverageSourceOptions($scope.target); - }; - $scope.removeMetricAgg = function() { metricAggs.splice($scope.index, 1); $scope.onChange(); diff --git a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html index 2e34b28612d..e7f726c1616 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html @@ -33,7 +33,7 @@ Based on
    • - +
    diff --git a/public/app/plugins/datasource/elasticsearch/query_def.js b/public/app/plugins/datasource/elasticsearch/query_def.js index 865c74753b3..885704c4d25 100644 --- a/public/app/plugins/datasource/elasticsearch/query_def.js +++ b/public/app/plugins/datasource/elasticsearch/query_def.js @@ -13,7 +13,7 @@ function (_) { {text: "Min", value: 'min', requiresField: true}, {text: "Extended Stats", value: 'extended_stats', requiresField: true}, {text: "Percentiles", value: 'percentiles', requiresField: true}, - {text: "Moving Avg", value: 'moving_avg', requiresField: false }, + {text: "Moving Average", value: 'moving_avg', requiresField: false }, {text: "Unique Count", value: "cardinality", requiresField: true}, {text: "Raw Document", value: "raw_document", requiresField: false} ], From d3ff4bf75e5936027320acea56bc9bb82c7f8c37 Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Wed, 9 Dec 2015 13:55:06 +0100 Subject: [PATCH 08/27] changes to using an array for mavg options --- .../datasource/elasticsearch/metric_agg.js | 19 +++++++++++-------- .../elasticsearch/partials/metricAgg.html | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/metric_agg.js b/public/app/plugins/datasource/elasticsearch/metric_agg.js index 157ee95a6c4..6db0ad7b48d 100644 --- a/public/app/plugins/datasource/elasticsearch/metric_agg.js +++ b/public/app/plugins/datasource/elasticsearch/metric_agg.js @@ -13,14 +13,21 @@ function (angular, _, queryDef) { $scope.metricAggTypes = queryDef.metricAggTypes; $scope.extendedStats = queryDef.extendedStats; + $scope.mavgOptions = []; $scope.init = function() { $scope.agg = metricAggs[$scope.index]; $scope.validateModel(); + $scope.updateMavgOptions(); + }; + + $scope.updateMavgOptions = function() { + $scope.mavgOptions = queryDef.getMovingAverageSourceOptions($scope.target); }; $rootScope.onAppEvent('elastic-query-updated', function() { $scope.index = _.indexOf(metricAggs, $scope.agg); + $scope.updateMavgOptions(); $scope.validateModel(); }, $scope); @@ -30,14 +37,15 @@ function (angular, _, queryDef) { $scope.settingsLinkText = ''; $scope.aggDef = _.findWhere($scope.metricAggTypes, {value: $scope.agg.type}); - if (!$scope.agg.field) { + if (!$scope.agg.field && $scope.agg.type !== 'moving_avg') { $scope.agg.field = 'select field'; } switch($scope.agg.type) { case 'moving_avg': { - $scope.agg.mavgSource = $scope.agg.mavgSource || 'Basec on metric'; + $scope.agg.mavgSource = $scope.agg.mavgSource || 'Metric to apply moving average'; $scope.settingsLinkText = 'Moving average options'; + $scope.agg.field = $scope.agg.mavgSource; break; } case 'percentiles': { @@ -70,7 +78,7 @@ function (angular, _, queryDef) { $scope.toggleOptions = function() { $scope.showOptions = !$scope.showOptions; - $scope.updateMovingAverageOptions(); + $scope.updateMavgOptions(); }; $scope.onChangeInternal = function() { @@ -88,11 +96,6 @@ function (angular, _, queryDef) { return $scope.getFields({$fieldType: 'number'}); }; - $scope.mavgSourceOptions = function() { - return $q.when(queryDef.getMovingAverageSourceOptions($scope.target)) - .then(uiSegmentSrv.transformToSegments(false)); - }; - $scope.addMetricAgg = function() { var addIndex = metricAggs.length; diff --git a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html index e7f726c1616..3ddec210ceb 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html @@ -33,7 +33,7 @@ Based on
  • - +
  • From 0b285845d1bda46a553881621b7fcaa7dab5a172 Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Wed, 9 Dec 2015 14:21:48 +0100 Subject: [PATCH 09/27] adds spec for query builder --- .../datasource/elasticsearch/metric_agg.js | 2 +- .../datasource/elasticsearch/query_builder.js | 6 ++- .../specs/query_builder_specs.ts | 47 +++++++++++++++++-- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/metric_agg.js b/public/app/plugins/datasource/elasticsearch/metric_agg.js index 6db0ad7b48d..149623bdd9b 100644 --- a/public/app/plugins/datasource/elasticsearch/metric_agg.js +++ b/public/app/plugins/datasource/elasticsearch/metric_agg.js @@ -37,7 +37,7 @@ function (angular, _, queryDef) { $scope.settingsLinkText = ''; $scope.aggDef = _.findWhere($scope.metricAggTypes, {value: $scope.agg.type}); - if (!$scope.agg.field && $scope.agg.type !== 'moving_avg') { + if (!$scope.agg.field) { $scope.agg.field = 'select field'; } diff --git a/public/app/plugins/datasource/elasticsearch/query_builder.js b/public/app/plugins/datasource/elasticsearch/query_builder.js index 5cd7d1dae50..967f8851495 100644 --- a/public/app/plugins/datasource/elasticsearch/query_builder.js +++ b/public/app/plugins/datasource/elasticsearch/query_builder.js @@ -171,7 +171,11 @@ function () { var metricAgg = null; if (metric.type === 'moving_avg') { - metricAgg = {buckets_path: "1"}; + if (metric.mavgSource && /^\d*$/.test(metric.mavgSource)) { + metricAgg = { buckets_path: metric.mavgSource }; + } else { + continue; + } } else { metricAgg = {field: metric.field}; } diff --git a/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts b/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts index 0bda6ab73b1..3c2c52916cb 100644 --- a/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts +++ b/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts @@ -158,11 +158,16 @@ describe('ElasticQueryBuilder', function() { it('with moving average', function() { var query = builder.build({ metrics: [ + { + id: '3', + type: 'sum', + field: '@value' + }, { id: '2', type: 'moving_avg', - field: '@value', - aggregation: 'sum' + field: '3', + mavgSource: '3' } ], bucketAggs: [ @@ -171,9 +176,43 @@ describe('ElasticQueryBuilder', function() { }); var firstLevel = query.aggs["3"]; - console.log(JSON.stringify(query)); + expect(firstLevel.aggs["2"]).not.to.be(undefined); expect(firstLevel.aggs["2"].moving_avg).not.to.be(undefined); - expect(firstLevel.aggs["2"].moving_avg.buckets_path).to.be("99"); + expect(firstLevel.aggs["2"].moving_avg.buckets_path).to.be("3"); + }); + + it('with broken moving average', function() { + var query = builder.build({ + metrics: [ + { + id: '3', + type: 'sum', + field: '@value' + }, + { + id: '2', + type: 'moving_avg', + field: '3', + mavgSource: '3' + }, + { + id: '4', + type: 'moving_avg', + field: '3', + mavgSource: 'Metric to apply moving average' + } + ], + bucketAggs: [ + { type: 'date_histogram', field: '@timestamp', id: '3' } + ], + }); + + var firstLevel = query.aggs["3"]; + + expect(firstLevel.aggs["2"]).not.to.be(undefined); + expect(firstLevel.aggs["2"].moving_avg).not.to.be(undefined); + expect(firstLevel.aggs["2"].moving_avg.buckets_path).to.be("3"); + expect(firstLevel.aggs["4"]).to.be(undefined); }); }); From 0644bfe27cc62d9df7e903847ebc6d4970f5de4e Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Wed, 9 Dec 2015 14:58:26 +0100 Subject: [PATCH 10/27] improves timeseries naming for moving average series --- .../app/plugins/datasource/elasticsearch/elastic_response.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/elasticsearch/elastic_response.js b/public/app/plugins/datasource/elasticsearch/elastic_response.js index a7c8e6d14bf..1994102bc82 100644 --- a/public/app/plugins/datasource/elasticsearch/elastic_response.js +++ b/public/app/plugins/datasource/elasticsearch/elastic_response.js @@ -197,7 +197,10 @@ function (_, queryDef) { }); } - if (series.field) { + if (series.field && series.metric === 'moving_avg') { + var appliedAgg = _.findWhere(target.metrics, { id: series.field }); + metricName += ' ' + queryDef.describeMetric(appliedAgg); + } else if (series.field) { metricName += ' ' + series.field; } From 8e18f2c5d2fd093c71d6761059499133b6dc2dc5 Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Wed, 9 Dec 2015 16:25:05 +0100 Subject: [PATCH 11/27] refactor es pipeline aggregation variables to match ES --- .../elasticsearch/elastic_response.js | 6 +- .../datasource/elasticsearch/metric_agg.js | 6 +- .../elasticsearch/partials/metricAgg.html | 2 +- .../datasource/elasticsearch/query_builder.js | 4 +- .../datasource/elasticsearch/query_def.js | 12 ++- .../specs/query_builder_specs.ts | 6 +- .../elasticsearch/specs/query_def_specs.ts | 74 ++++++++++++------- 7 files changed, 72 insertions(+), 38 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/elastic_response.js b/public/app/plugins/datasource/elasticsearch/elastic_response.js index 1994102bc82..fd53873aa8d 100644 --- a/public/app/plugins/datasource/elasticsearch/elastic_response.js +++ b/public/app/plugins/datasource/elasticsearch/elastic_response.js @@ -199,7 +199,11 @@ function (_, queryDef) { if (series.field && series.metric === 'moving_avg') { var appliedAgg = _.findWhere(target.metrics, { id: series.field }); - metricName += ' ' + queryDef.describeMetric(appliedAgg); + if (appliedAgg) { + metricName += ' ' + queryDef.describeMetric(appliedAgg); + } else { + metricName = 'Unset'; + } } else if (series.field) { metricName += ' ' + series.field; } diff --git a/public/app/plugins/datasource/elasticsearch/metric_agg.js b/public/app/plugins/datasource/elasticsearch/metric_agg.js index 149623bdd9b..1d6f82a292f 100644 --- a/public/app/plugins/datasource/elasticsearch/metric_agg.js +++ b/public/app/plugins/datasource/elasticsearch/metric_agg.js @@ -22,7 +22,7 @@ function (angular, _, queryDef) { }; $scope.updateMavgOptions = function() { - $scope.mavgOptions = queryDef.getMovingAverageSourceOptions($scope.target); + $scope.mavgOptions = queryDef.getMovingAverageOptions($scope.target); }; $rootScope.onAppEvent('elastic-query-updated', function() { @@ -43,9 +43,9 @@ function (angular, _, queryDef) { switch($scope.agg.type) { case 'moving_avg': { - $scope.agg.mavgSource = $scope.agg.mavgSource || 'Metric to apply moving average'; + $scope.agg.pipelineAgg = $scope.agg.pipelineAgg || 'Metric to apply moving average'; $scope.settingsLinkText = 'Moving average options'; - $scope.agg.field = $scope.agg.mavgSource; + $scope.agg.field = $scope.agg.pipelineAgg; break; } case 'percentiles': { diff --git a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html index 3ddec210ceb..7c21e64721e 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html @@ -33,7 +33,7 @@ Based on
  • - +
  • diff --git a/public/app/plugins/datasource/elasticsearch/query_builder.js b/public/app/plugins/datasource/elasticsearch/query_builder.js index 967f8851495..64128943f40 100644 --- a/public/app/plugins/datasource/elasticsearch/query_builder.js +++ b/public/app/plugins/datasource/elasticsearch/query_builder.js @@ -171,8 +171,8 @@ function () { var metricAgg = null; if (metric.type === 'moving_avg') { - if (metric.mavgSource && /^\d*$/.test(metric.mavgSource)) { - metricAgg = { buckets_path: metric.mavgSource }; + if (metric.pipelineAgg && /^\d*$/.test(metric.pipelineAgg)) { + metricAgg = { buckets_path: metric.pipelineAgg }; } else { continue; } diff --git a/public/app/plugins/datasource/elasticsearch/query_def.js b/public/app/plugins/datasource/elasticsearch/query_def.js index 885704c4d25..6fed5580576 100644 --- a/public/app/plugins/datasource/elasticsearch/query_def.js +++ b/public/app/plugins/datasource/elasticsearch/query_def.js @@ -67,7 +67,17 @@ function (_) { {text: '1d', value: '1d'}, ], - getMovingAverageSourceOptions: function(targets) { + pipelineAggs: ['moving_avg'], + + isPipelineAgg: function(metric) { + if (metric.type) { + return this.pipelineAggs.indexOf(metric.type) > -1; + } + + return false; + }, + + getMovingAverageOptions: function(targets) { var self = this; var result = []; _.each(targets.metrics, function(metric) { diff --git a/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts b/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts index 3c2c52916cb..91cdba7248e 100644 --- a/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts +++ b/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts @@ -167,7 +167,7 @@ describe('ElasticQueryBuilder', function() { id: '2', type: 'moving_avg', field: '3', - mavgSource: '3' + pipelineAgg: '3' } ], bucketAggs: [ @@ -194,13 +194,13 @@ describe('ElasticQueryBuilder', function() { id: '2', type: 'moving_avg', field: '3', - mavgSource: '3' + pipelineAgg: '3' }, { id: '4', type: 'moving_avg', field: '3', - mavgSource: 'Metric to apply moving average' + pipelineAgg: 'Metric to apply moving average' } ], bucketAggs: [ diff --git a/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts b/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts index 18d22f794d5..cf375430ae1 100644 --- a/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts +++ b/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts @@ -8,41 +8,61 @@ declare var QueryDef: any; describe('ElasticQueryDef', function() { - describe('with zero targets', function() { - var response = QueryDef.getMovingAverageSourceOptions([]); + describe('getMovingAverageOptions', function() { + describe('with zero targets', function() { + var response = QueryDef.getMovingAverageOptions([]); - it('should return zero', function() { - expect(response.length).to.be(0); + it('should return zero', function() { + expect(response.length).to.be(0); + }); + }); + + describe('with count and sum targets', function() { + var targets = { + metrics: [ + { type: 'count', field: '@value' }, + { type: 'sum', field: '@value' } + ] + }; + + var response = QueryDef.getMovingAverageOptions(targets); + + it('should return zero', function() { + expect(response.length).to.be(2); + }); + }); + + describe('with count and moving average targets', function() { + var targets = { + metrics: [ + { type: 'count', field: '@value' }, + { type: 'moving_avg', field: '@value' } + ] + }; + + var response = QueryDef.getMovingAverageOptions(targets); + + it('should return zero', function() { + expect(response.length).to.be(1); + }); }); }); - describe('with count and sum targets', function() { - var targets = { - metrics: [ - { type: 'count', field: '@value' }, - { type: 'sum', field: '@value' } - ] - }; + describe('isPipelineMetric', function() { + describe('moving_avg', function() { + var result = QueryDef.isPipelineAgg({ type: 'moving_avg' }); - var response = QueryDef.getMovingAverageSourceOptions(targets); - - it('should return zero', function() { - expect(response.length).to.be(2); + it('is pipe line metric', function() { + expect(result).to.be(true); + }); }); - }); - describe('with count and moving average targets', function() { - var targets = { - metrics: [ - { type: 'count', field: '@value' }, - { type: 'moving_avg', field: '@value' } - ] - }; + describe('count', function() { + var result = QueryDef.isPipelineAgg({ type: 'count' }); - var response = QueryDef.getMovingAverageSourceOptions(targets); - - it('should return zero', function() { - expect(response.length).to.be(1); + it('is not pipe line metric', function() { + expect(result).to.be(false); + }); }); }); }); From e86dfcf55cbb89d5879ed172c15e00021dde9cd8 Mon Sep 17 00:00:00 2001 From: Carl Bergquist Date: Thu, 10 Dec 2015 10:43:00 +0100 Subject: [PATCH 12/27] rename mavgoptions to more generic pipelineaggs --- .../plugins/datasource/elasticsearch/metric_agg.js | 12 ++++++------ .../datasource/elasticsearch/partials/metricAgg.html | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/metric_agg.js b/public/app/plugins/datasource/elasticsearch/metric_agg.js index 1d6f82a292f..471c0a17959 100644 --- a/public/app/plugins/datasource/elasticsearch/metric_agg.js +++ b/public/app/plugins/datasource/elasticsearch/metric_agg.js @@ -13,21 +13,21 @@ function (angular, _, queryDef) { $scope.metricAggTypes = queryDef.metricAggTypes; $scope.extendedStats = queryDef.extendedStats; - $scope.mavgOptions = []; + $scope.pipelineAggOptions = []; $scope.init = function() { $scope.agg = metricAggs[$scope.index]; $scope.validateModel(); - $scope.updateMavgOptions(); + $scope.updatePipelineAggOptions(); }; - $scope.updateMavgOptions = function() { - $scope.mavgOptions = queryDef.getMovingAverageOptions($scope.target); + $scope.updatePipelineAggOptions = function() { + $scope.pipelineAggOptions = queryDef.getMovingAverageOptions($scope.target); }; $rootScope.onAppEvent('elastic-query-updated', function() { $scope.index = _.indexOf(metricAggs, $scope.agg); - $scope.updateMavgOptions(); + $scope.updatePipelineAggOptions(); $scope.validateModel(); }, $scope); @@ -78,7 +78,7 @@ function (angular, _, queryDef) { $scope.toggleOptions = function() { $scope.showOptions = !$scope.showOptions; - $scope.updateMavgOptions(); + $scope.updatePipelineAggOptions(); }; $scope.onChangeInternal = function() { diff --git a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html index 7c21e64721e..0fb58cff328 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html @@ -33,7 +33,7 @@ Based on
  • - +
  • From 9c6eb7736fd30d6db04b0c2314244f7f94adc1f0 Mon Sep 17 00:00:00 2001 From: Carl Bergquist Date: Thu, 10 Dec 2015 11:17:14 +0100 Subject: [PATCH 13/27] move pipeline options outside main switch --- .../plugins/datasource/elasticsearch/metric_agg.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/metric_agg.js b/public/app/plugins/datasource/elasticsearch/metric_agg.js index 471c0a17959..37fe224b586 100644 --- a/public/app/plugins/datasource/elasticsearch/metric_agg.js +++ b/public/app/plugins/datasource/elasticsearch/metric_agg.js @@ -41,13 +41,13 @@ function (angular, _, queryDef) { $scope.agg.field = 'select field'; } + if (queryDef.isPipelineAgg($scope.agg)) { + $scope.agg.pipelineAgg = $scope.agg.pipelineAgg || 'select metric'; + $scope.agg.field = $scope.agg.pipelineAgg; + $scope.settingsLinkText = 'Options'; + } + switch($scope.agg.type) { - case 'moving_avg': { - $scope.agg.pipelineAgg = $scope.agg.pipelineAgg || 'Metric to apply moving average'; - $scope.settingsLinkText = 'Moving average options'; - $scope.agg.field = $scope.agg.pipelineAgg; - break; - } case 'percentiles': { $scope.agg.settings.percents = $scope.agg.settings.percents || [25,50,75,95,99]; $scope.settingsLinkText = 'values: ' + $scope.agg.settings.percents.join(','); From b36f6446280504284bc7974e266e2350e0b9bf8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 10 Dec 2015 11:46:19 +0100 Subject: [PATCH 14/27] feat(elasticsearch): added pipleline aggregation derivative --- .../datasource/elasticsearch/metric_agg.js | 7 ++--- .../datasource/elasticsearch/query_builder.js | 9 ++++-- .../datasource/elasticsearch/query_def.js | 3 +- .../specs/query_builder_specs.ts | 29 +++++++++++++++++-- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/metric_agg.js b/public/app/plugins/datasource/elasticsearch/metric_agg.js index 37fe224b586..feaa4bac0b6 100644 --- a/public/app/plugins/datasource/elasticsearch/metric_agg.js +++ b/public/app/plugins/datasource/elasticsearch/metric_agg.js @@ -37,14 +37,13 @@ function (angular, _, queryDef) { $scope.settingsLinkText = ''; $scope.aggDef = _.findWhere($scope.metricAggTypes, {value: $scope.agg.type}); - if (!$scope.agg.field) { - $scope.agg.field = 'select field'; - } - if (queryDef.isPipelineAgg($scope.agg)) { $scope.agg.pipelineAgg = $scope.agg.pipelineAgg || 'select metric'; $scope.agg.field = $scope.agg.pipelineAgg; $scope.settingsLinkText = 'Options'; + delete $scope.agg.field; + } else if (!$scope.agg.field) { + $scope.agg.field = 'select field'; } switch($scope.agg.type) { diff --git a/public/app/plugins/datasource/elasticsearch/query_builder.js b/public/app/plugins/datasource/elasticsearch/query_builder.js index 64128943f40..c68827df853 100644 --- a/public/app/plugins/datasource/elasticsearch/query_builder.js +++ b/public/app/plugins/datasource/elasticsearch/query_builder.js @@ -1,6 +1,7 @@ define([ + './query_def' ], -function () { +function (queryDef) { 'use strict'; function ElasticQueryBuilder(options) { @@ -170,9 +171,11 @@ function () { var aggField = {}; var metricAgg = null; - if (metric.type === 'moving_avg') { + if (queryDef.isPipelineAgg(metric)) { if (metric.pipelineAgg && /^\d*$/.test(metric.pipelineAgg)) { - metricAgg = { buckets_path: metric.pipelineAgg }; + metricAgg = { + buckets_path: metric.pipelineAgg, + }; } else { continue; } diff --git a/public/app/plugins/datasource/elasticsearch/query_def.js b/public/app/plugins/datasource/elasticsearch/query_def.js index 6fed5580576..a7c30a7a710 100644 --- a/public/app/plugins/datasource/elasticsearch/query_def.js +++ b/public/app/plugins/datasource/elasticsearch/query_def.js @@ -14,6 +14,7 @@ function (_) { {text: "Extended Stats", value: 'extended_stats', requiresField: true}, {text: "Percentiles", value: 'percentiles', requiresField: true}, {text: "Moving Average", value: 'moving_avg', requiresField: false }, + {text: "Derivative", value: 'derivative', requiresField: false }, {text: "Unique Count", value: "cardinality", requiresField: true}, {text: "Raw Document", value: "raw_document", requiresField: false} ], @@ -67,7 +68,7 @@ function (_) { {text: '1d', value: '1d'}, ], - pipelineAggs: ['moving_avg'], + pipelineAggs: ['moving_avg', 'derivative'], isPipelineAgg: function(metric) { if (metric.type) { diff --git a/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts b/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts index 91cdba7248e..0be35b20a38 100644 --- a/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts +++ b/public/app/plugins/datasource/elasticsearch/specs/query_builder_specs.ts @@ -193,13 +193,11 @@ describe('ElasticQueryBuilder', function() { { id: '2', type: 'moving_avg', - field: '3', pipelineAgg: '3' }, { id: '4', type: 'moving_avg', - field: '3', pipelineAgg: 'Metric to apply moving average' } ], @@ -215,4 +213,31 @@ describe('ElasticQueryBuilder', function() { expect(firstLevel.aggs["2"].moving_avg.buckets_path).to.be("3"); expect(firstLevel.aggs["4"]).to.be(undefined); }); + + it('with derivative', function() { + var query = builder.build({ + metrics: [ + { + id: '3', + type: 'sum', + field: '@value' + }, + { + id: '2', + type: 'derivative', + pipelineAgg: '3' + } + ], + bucketAggs: [ + {type: 'date_histogram', field: '@timestamp', id: '3'} + ], + }); + + var firstLevel = query.aggs["3"]; + + expect(firstLevel.aggs["2"]).not.to.be(undefined); + expect(firstLevel.aggs["2"].derivative).not.to.be(undefined); + expect(firstLevel.aggs["2"].derivative.buckets_path).to.be("3"); + }); + }); From 1bb0530c6979586c0a10de820be69aabbcb7c184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 10 Dec 2015 12:15:11 +0100 Subject: [PATCH 15/27] feat(elasticsearch): metric options alignement --- .../datasource/elasticsearch/partials/metricAgg.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html index 0fb58cff328..54c6ab26832 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html @@ -9,8 +9,15 @@
  • +
  • +   +
  • - {{settingsLinkText}} + + + + {{settingsLinkText}} +
  • From 2d2ad8b237625a689512d9e0c7d6f70c50087b45 Mon Sep 17 00:00:00 2001 From: Carl Bergquist Date: Thu, 10 Dec 2015 13:06:46 +0100 Subject: [PATCH 16/27] show pipeline agg source for derivative --- .../plugins/datasource/elasticsearch/partials/metricAgg.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html index 54c6ab26832..f99f46bee19 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html @@ -34,7 +34,7 @@
    -
    +
    • Based on From 85094fc74d726b9f49041741459884973e6fe34e Mon Sep 17 00:00:00 2001 From: Carl Bergquist Date: Thu, 10 Dec 2015 13:34:49 +0100 Subject: [PATCH 17/27] feat(elasticsearch): add pipeline settings --- .../plugins/datasource/elasticsearch/metric_agg.js | 3 +++ .../elasticsearch/partials/metricAgg.html | 13 +++++++++++++ .../plugins/datasource/elasticsearch/query_def.js | 13 +++++++++++++ 3 files changed, 29 insertions(+) diff --git a/public/app/plugins/datasource/elasticsearch/metric_agg.js b/public/app/plugins/datasource/elasticsearch/metric_agg.js index feaa4bac0b6..6f52dc4f28d 100644 --- a/public/app/plugins/datasource/elasticsearch/metric_agg.js +++ b/public/app/plugins/datasource/elasticsearch/metric_agg.js @@ -13,12 +13,15 @@ function (angular, _, queryDef) { $scope.metricAggTypes = queryDef.metricAggTypes; $scope.extendedStats = queryDef.extendedStats; + $scope.pipelineSettings = []; + $scope.pipelineAggOptions = []; $scope.init = function() { $scope.agg = metricAggs[$scope.index]; $scope.validateModel(); $scope.updatePipelineAggOptions(); + $scope.pipelineSettings = queryDef.getPipelineSettings($scope.agg); }; $scope.updatePipelineAggOptions = function() { diff --git a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html index f99f46bee19..ecbfa3d7df1 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html @@ -45,6 +45,19 @@
    +
    +
    +
      +
    • + {{stat.text}} +
    • +
    • + +
    • +
    +
    +
    +
    • diff --git a/public/app/plugins/datasource/elasticsearch/query_def.js b/public/app/plugins/datasource/elasticsearch/query_def.js index a7c30a7a710..361dbfd5e1d 100644 --- a/public/app/plugins/datasource/elasticsearch/query_def.js +++ b/public/app/plugins/datasource/elasticsearch/query_def.js @@ -70,6 +70,19 @@ function (_) { pipelineAggs: ['moving_avg', 'derivative'], + pipelineSettings: { + 'moving_avg' : ['model', 'gap_policy', 'window', 'minimize'], + 'derivative': [] + }, + + getPipelineSettings: function(metric) { + if (this.isPipelineAgg(metric) === false) { + return []; + } + + return this.pipelineSettings[metric.type]; + }, + isPipelineAgg: function(metric) { if (metric.type) { return this.pipelineAggs.indexOf(metric.type) > -1; From 0f65cb2b79175669f22f6aaf8b590d2676242b56 Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Thu, 10 Dec 2015 17:01:29 +0100 Subject: [PATCH 18/27] feat(elasticsearch): update pipeline aggs if type change make it possible to switch between different pipeline aggregates without causing problms in the ui --- public/app/plugins/datasource/elasticsearch/metric_agg.js | 1 + public/app/plugins/datasource/elasticsearch/query_builder.js | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/metric_agg.js b/public/app/plugins/datasource/elasticsearch/metric_agg.js index 6f52dc4f28d..9ac70580e51 100644 --- a/public/app/plugins/datasource/elasticsearch/metric_agg.js +++ b/public/app/plugins/datasource/elasticsearch/metric_agg.js @@ -91,6 +91,7 @@ function (angular, _, queryDef) { $scope.agg.settings = {}; $scope.agg.meta = {}; $scope.showOptions = false; + $scope.updatePipelineAggOptions(); $scope.onChange(); }; diff --git a/public/app/plugins/datasource/elasticsearch/query_builder.js b/public/app/plugins/datasource/elasticsearch/query_builder.js index c68827df853..5e6335e032e 100644 --- a/public/app/plugins/datasource/elasticsearch/query_builder.js +++ b/public/app/plugins/datasource/elasticsearch/query_builder.js @@ -173,9 +173,7 @@ function (queryDef) { if (queryDef.isPipelineAgg(metric)) { if (metric.pipelineAgg && /^\d*$/.test(metric.pipelineAgg)) { - metricAgg = { - buckets_path: metric.pipelineAgg, - }; + metricAgg = { buckets_path: metric.pipelineAgg }; } else { continue; } From c8c9e0a7e77e0168ae57f309f41958626c190d65 Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Thu, 10 Dec 2015 17:03:46 +0100 Subject: [PATCH 19/27] feat(elasticsearch): improve pipeline aggs structure --- .../datasource/elasticsearch/metric_agg.js | 9 ++++--- .../elasticsearch/partials/metricAgg.html | 26 +++++++++---------- .../datasource/elasticsearch/query_def.js | 17 ++++++------ 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/metric_agg.js b/public/app/plugins/datasource/elasticsearch/metric_agg.js index 9ac70580e51..8bd1b596245 100644 --- a/public/app/plugins/datasource/elasticsearch/metric_agg.js +++ b/public/app/plugins/datasource/elasticsearch/metric_agg.js @@ -13,15 +13,12 @@ function (angular, _, queryDef) { $scope.metricAggTypes = queryDef.metricAggTypes; $scope.extendedStats = queryDef.extendedStats; - $scope.pipelineSettings = []; - $scope.pipelineAggOptions = []; $scope.init = function() { $scope.agg = metricAggs[$scope.index]; $scope.validateModel(); $scope.updatePipelineAggOptions(); - $scope.pipelineSettings = queryDef.getPipelineSettings($scope.agg); }; $scope.updatePipelineAggOptions = function() { @@ -44,7 +41,11 @@ function (angular, _, queryDef) { $scope.agg.pipelineAgg = $scope.agg.pipelineAgg || 'select metric'; $scope.agg.field = $scope.agg.pipelineAgg; $scope.settingsLinkText = 'Options'; - delete $scope.agg.field; + + _.each(queryDef.getPipelineOptions($scope.agg), function(opt) { + $scope.agg.settings[opt.text] = $scope.agg.settings[opt.text] || opt.default; + }); + } else if (!$scope.agg.field) { $scope.agg.field = 'select field'; } diff --git a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html index ecbfa3d7df1..009e5ff65f5 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html @@ -34,9 +34,9 @@
      -
      +
        -
      • +
      • Based on
      • @@ -45,18 +45,16 @@
      -
      -
      -
        -
      • - {{stat.text}} -
      • -
      • - -
      • -
      -
      -
      +
      +
        +
      • + Window +
      • +
      • + +
      • +
      +
        diff --git a/public/app/plugins/datasource/elasticsearch/query_def.js b/public/app/plugins/datasource/elasticsearch/query_def.js index 361dbfd5e1d..2cd7e97e145 100644 --- a/public/app/plugins/datasource/elasticsearch/query_def.js +++ b/public/app/plugins/datasource/elasticsearch/query_def.js @@ -68,24 +68,25 @@ function (_) { {text: '1d', value: '1d'}, ], - pipelineAggs: ['moving_avg', 'derivative'], - - pipelineSettings: { - 'moving_avg' : ['model', 'gap_policy', 'window', 'minimize'], + pipelineOptions: { + 'moving_avg' : [ + {text: 'window', default: 5} + ], 'derivative': [] }, - getPipelineSettings: function(metric) { - if (this.isPipelineAgg(metric) === false) { + getPipelineOptions: function(metric) { + if (!this.isPipelineAgg(metric)) { return []; } - return this.pipelineSettings[metric.type]; + return this.pipelineOptions[metric.type]; }, isPipelineAgg: function(metric) { if (metric.type) { - return this.pipelineAggs.indexOf(metric.type) > -1; + var po = this.pipelineOptions[metric.type]; + return po !== null && po !== undefined; } return false; From 005e14a060af39d7999f11f43ff59c7e96b7a09c Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Thu, 10 Dec 2015 17:12:52 +0100 Subject: [PATCH 20/27] refactor(elasticsearch): mavg naming -> pipeline agg --- public/app/plugins/datasource/elasticsearch/metric_agg.js | 2 +- public/app/plugins/datasource/elasticsearch/query_def.js | 2 +- .../datasource/elasticsearch/specs/query_def_specs.ts | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/metric_agg.js b/public/app/plugins/datasource/elasticsearch/metric_agg.js index 8bd1b596245..dedb2436b11 100644 --- a/public/app/plugins/datasource/elasticsearch/metric_agg.js +++ b/public/app/plugins/datasource/elasticsearch/metric_agg.js @@ -22,7 +22,7 @@ function (angular, _, queryDef) { }; $scope.updatePipelineAggOptions = function() { - $scope.pipelineAggOptions = queryDef.getMovingAverageOptions($scope.target); + $scope.pipelineAggOptions = queryDef.getPipelineAggOptions($scope.target); }; $rootScope.onAppEvent('elastic-query-updated', function() { diff --git a/public/app/plugins/datasource/elasticsearch/query_def.js b/public/app/plugins/datasource/elasticsearch/query_def.js index 2cd7e97e145..f5f4cc600e4 100644 --- a/public/app/plugins/datasource/elasticsearch/query_def.js +++ b/public/app/plugins/datasource/elasticsearch/query_def.js @@ -92,7 +92,7 @@ function (_) { return false; }, - getMovingAverageOptions: function(targets) { + getPipelineAggOptions: function(targets) { var self = this; var result = []; _.each(targets.metrics, function(metric) { diff --git a/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts b/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts index cf375430ae1..7f8be653dfc 100644 --- a/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts +++ b/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts @@ -8,9 +8,9 @@ declare var QueryDef: any; describe('ElasticQueryDef', function() { - describe('getMovingAverageOptions', function() { + describe('getPipelineAggOptions', function() { describe('with zero targets', function() { - var response = QueryDef.getMovingAverageOptions([]); + var response = QueryDef.getPipelineAggOptions([]); it('should return zero', function() { expect(response.length).to.be(0); @@ -25,7 +25,7 @@ describe('ElasticQueryDef', function() { ] }; - var response = QueryDef.getMovingAverageOptions(targets); + var response = QueryDef.getPipelineAggOptions(targets); it('should return zero', function() { expect(response.length).to.be(2); @@ -40,7 +40,7 @@ describe('ElasticQueryDef', function() { ] }; - var response = QueryDef.getMovingAverageOptions(targets); + var response = QueryDef.getPipelineAggOptions(targets); it('should return zero', function() { expect(response.length).to.be(1); From 6e50e2412e061895aab6e350f2d06a0ce6480e3d Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Thu, 10 Dec 2015 17:18:22 +0100 Subject: [PATCH 21/27] feat(elasticsearch): remove pipeline aggs as possible sources --- .../datasource/elasticsearch/query_def.js | 2 +- .../elasticsearch/specs/query_def_specs.ts | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/query_def.js b/public/app/plugins/datasource/elasticsearch/query_def.js index f5f4cc600e4..e84ff00aab9 100644 --- a/public/app/plugins/datasource/elasticsearch/query_def.js +++ b/public/app/plugins/datasource/elasticsearch/query_def.js @@ -96,7 +96,7 @@ function (_) { var self = this; var result = []; _.each(targets.metrics, function(metric) { - if (metric.type !== 'moving_avg') { + if (!self.isPipelineAgg(metric)) { result.push({text: self.describeMetric(metric), value: metric.id }); } }); diff --git a/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts b/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts index 7f8be653dfc..153639d3d9a 100644 --- a/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts +++ b/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts @@ -42,10 +42,24 @@ describe('ElasticQueryDef', function() { var response = QueryDef.getPipelineAggOptions(targets); - it('should return zero', function() { + it('should return one', function() { expect(response.length).to.be(1); }); }); + + describe('with derivatives targets', function() { + var targets = { + metrics: [ + { type: 'derivative', field: '@value' } + ] + }; + + var response = QueryDef.getPipelineAggOptions(targets); + + it('should return zero', function() { + expect(response.length).to.be(0); + }); + }); }); describe('isPipelineMetric', function() { From 139b19f9ac906029e7ebcceec01d62beaf542bd5 Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Thu, 10 Dec 2015 17:42:31 +0100 Subject: [PATCH 22/27] feat(elasticsearch): make series naming generic for pipeline aggs --- .../datasource/elasticsearch/elastic_response.js | 2 +- .../app/plugins/datasource/elasticsearch/metric_agg.js | 2 +- .../plugins/datasource/elasticsearch/query_builder.js | 2 +- .../app/plugins/datasource/elasticsearch/query_def.js | 10 +++++----- .../datasource/elasticsearch/specs/query_def_specs.ts | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/elastic_response.js b/public/app/plugins/datasource/elasticsearch/elastic_response.js index fd53873aa8d..bcf4983f9a6 100644 --- a/public/app/plugins/datasource/elasticsearch/elastic_response.js +++ b/public/app/plugins/datasource/elasticsearch/elastic_response.js @@ -197,7 +197,7 @@ function (_, queryDef) { }); } - if (series.field && series.metric === 'moving_avg') { + if (series.field && queryDef.isPipelineAgg(series.metric)) { var appliedAgg = _.findWhere(target.metrics, { id: series.field }); if (appliedAgg) { metricName += ' ' + queryDef.describeMetric(appliedAgg); diff --git a/public/app/plugins/datasource/elasticsearch/metric_agg.js b/public/app/plugins/datasource/elasticsearch/metric_agg.js index dedb2436b11..f5272e29632 100644 --- a/public/app/plugins/datasource/elasticsearch/metric_agg.js +++ b/public/app/plugins/datasource/elasticsearch/metric_agg.js @@ -37,7 +37,7 @@ function (angular, _, queryDef) { $scope.settingsLinkText = ''; $scope.aggDef = _.findWhere($scope.metricAggTypes, {value: $scope.agg.type}); - if (queryDef.isPipelineAgg($scope.agg)) { + if (queryDef.isPipelineAgg($scope.agg.type)) { $scope.agg.pipelineAgg = $scope.agg.pipelineAgg || 'select metric'; $scope.agg.field = $scope.agg.pipelineAgg; $scope.settingsLinkText = 'Options'; diff --git a/public/app/plugins/datasource/elasticsearch/query_builder.js b/public/app/plugins/datasource/elasticsearch/query_builder.js index 5e6335e032e..dd071ba137d 100644 --- a/public/app/plugins/datasource/elasticsearch/query_builder.js +++ b/public/app/plugins/datasource/elasticsearch/query_builder.js @@ -171,7 +171,7 @@ function (queryDef) { var aggField = {}; var metricAgg = null; - if (queryDef.isPipelineAgg(metric)) { + if (queryDef.isPipelineAgg(metric.type)) { if (metric.pipelineAgg && /^\d*$/.test(metric.pipelineAgg)) { metricAgg = { buckets_path: metric.pipelineAgg }; } else { diff --git a/public/app/plugins/datasource/elasticsearch/query_def.js b/public/app/plugins/datasource/elasticsearch/query_def.js index e84ff00aab9..d0d49a5f05a 100644 --- a/public/app/plugins/datasource/elasticsearch/query_def.js +++ b/public/app/plugins/datasource/elasticsearch/query_def.js @@ -76,16 +76,16 @@ function (_) { }, getPipelineOptions: function(metric) { - if (!this.isPipelineAgg(metric)) { + if (!this.isPipelineAgg(metric.type)) { return []; } return this.pipelineOptions[metric.type]; }, - isPipelineAgg: function(metric) { - if (metric.type) { - var po = this.pipelineOptions[metric.type]; + isPipelineAgg: function(metricType) { + if (metricType) { + var po = this.pipelineOptions[metricType]; return po !== null && po !== undefined; } @@ -96,7 +96,7 @@ function (_) { var self = this; var result = []; _.each(targets.metrics, function(metric) { - if (!self.isPipelineAgg(metric)) { + if (!self.isPipelineAgg(metric.type)) { result.push({text: self.describeMetric(metric), value: metric.id }); } }); diff --git a/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts b/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts index 153639d3d9a..e2fda224a6a 100644 --- a/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts +++ b/public/app/plugins/datasource/elasticsearch/specs/query_def_specs.ts @@ -64,7 +64,7 @@ describe('ElasticQueryDef', function() { describe('isPipelineMetric', function() { describe('moving_avg', function() { - var result = QueryDef.isPipelineAgg({ type: 'moving_avg' }); + var result = QueryDef.isPipelineAgg('moving_avg'); it('is pipe line metric', function() { expect(result).to.be(true); @@ -72,7 +72,7 @@ describe('ElasticQueryDef', function() { }); describe('count', function() { - var result = QueryDef.isPipelineAgg({ type: 'count' }); + var result = QueryDef.isPipelineAgg('count'); it('is not pipe line metric', function() { expect(result).to.be(false); From 662430d5db602d98e894cd066f37c323c8b9b836 Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Fri, 11 Dec 2015 09:14:40 +0100 Subject: [PATCH 23/27] feat(elasticsearch): adds last class for derivatives --- .../plugins/datasource/elasticsearch/partials/metricAgg.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html index 009e5ff65f5..fb5c9a4f89f 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html @@ -34,7 +34,7 @@
        -
        +
        • Based on From 4fa92198a0dc8a3d05ca00f7fa2704f0202ab209 Mon Sep 17 00:00:00 2001 From: carl bergquist Date: Fri, 11 Dec 2015 09:19:05 +0100 Subject: [PATCH 24/27] feat(elasticsearch): add support for model setting --- .../elasticsearch/partials/metricAgg.html | 13 ++++++++++++- .../plugins/datasource/elasticsearch/query_def.js | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html index fb5c9a4f89f..eced5a12571 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/metricAgg.html @@ -45,7 +45,7 @@
        -
        +
        • Window @@ -56,6 +56,17 @@
        +
        +
          +
        • + Model +
        • +
        • + +
        • +
        +
        +