mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 12:14:08 -06:00
feat(elasticsearch): only show pipeline agg for es version >= 2
This commit is contained in:
parent
56c3dd3652
commit
f5eb54e595
@ -30,6 +30,7 @@ function (angular) {
|
||||
index: "=",
|
||||
onChange: "&",
|
||||
getFields: "&",
|
||||
esVersion: '='
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@ -11,7 +11,7 @@ function (angular, _, queryDef) {
|
||||
module.controller('ElasticMetricAggCtrl', function($scope, uiSegmentSrv, $q, $rootScope) {
|
||||
var metricAggs = $scope.target.metrics;
|
||||
|
||||
$scope.metricAggTypes = queryDef.metricAggTypes;
|
||||
$scope.metricAggTypes = queryDef.getMetricAggTypes($scope.esVersion);
|
||||
$scope.extendedStats = queryDef.extendedStats;
|
||||
$scope.pipelineAggOptions = [];
|
||||
|
||||
|
@ -65,7 +65,8 @@
|
||||
<elastic-metric-agg
|
||||
target="target" index="$index"
|
||||
get-fields="getFields($fieldType)"
|
||||
on-change="queryUpdated()">
|
||||
on-change="queryUpdated()"
|
||||
es-version="esVersion">
|
||||
</elastic-metric-agg>
|
||||
</div>
|
||||
|
||||
|
@ -7,6 +7,7 @@ function (angular) {
|
||||
var module = angular.module('grafana.controllers');
|
||||
|
||||
module.controller('ElasticQueryCtrl', function($scope, $timeout, uiSegmentSrv) {
|
||||
$scope.esVersion = $scope.datasource.esVersion;
|
||||
|
||||
$scope.init = function() {
|
||||
var target = $scope.target;
|
||||
|
@ -14,8 +14,8 @@ function (_) {
|
||||
{text: "Extended Stats", value: 'extended_stats', requiresField: true, supportsMissing: true, supportsInlineScript: true},
|
||||
{text: "Percentiles", value: 'percentiles', requiresField: true, supportsMissing: true, supportsInlineScript: true},
|
||||
{text: "Unique Count", value: "cardinality", requiresField: true, supportsMissing: true},
|
||||
{text: "Moving Average", value: 'moving_avg', requiresField: false, isPipelineAgg: true },
|
||||
{text: "Derivative", value: 'derivative', requiresField: false, isPipelineAgg: true },
|
||||
{text: "Moving Average", value: 'moving_avg', requiresField: false, isPipelineAgg: true, minVersion: 2},
|
||||
{text: "Derivative", value: 'derivative', requiresField: false, isPipelineAgg: true, minVersion: 2 },
|
||||
{text: "Raw Document", value: "raw_document", requiresField: false}
|
||||
],
|
||||
|
||||
@ -76,6 +76,16 @@ function (_) {
|
||||
'derivative': []
|
||||
},
|
||||
|
||||
getMetricAggTypes: function(esVersion) {
|
||||
return _.filter(this.metricAggTypes, function(f) {
|
||||
if (f.minVersion) {
|
||||
return f.minVersion <= esVersion;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
getPipelineOptions: function(metric) {
|
||||
if (!this.isPipelineAgg(metric.type)) {
|
||||
return [];
|
||||
|
@ -79,4 +79,24 @@ describe('ElasticQueryDef', function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('pipeline aggs depending on esverison', function() {
|
||||
describe('using esversion undefined', function() {
|
||||
it('should not get pipeline aggs', function() {
|
||||
expect(QueryDef.getMetricAggTypes(undefined).length).to.be(9);
|
||||
});
|
||||
});
|
||||
|
||||
describe('using esversion 1', function() {
|
||||
it('should not get pipeline aggs', function() {
|
||||
expect(QueryDef.getMetricAggTypes(1).length).to.be(9);
|
||||
});
|
||||
});
|
||||
|
||||
describe('using esversion 2', function() {
|
||||
it('should get pipeline aggs', function() {
|
||||
expect(QueryDef.getMetricAggTypes(2).length).to.be(11);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user