mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(elasticsearch): make series naming generic for pipeline aggs
This commit is contained in:
parent
6e50e2412e
commit
139b19f9ac
@ -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 });
|
var appliedAgg = _.findWhere(target.metrics, { id: series.field });
|
||||||
if (appliedAgg) {
|
if (appliedAgg) {
|
||||||
metricName += ' ' + queryDef.describeMetric(appliedAgg);
|
metricName += ' ' + queryDef.describeMetric(appliedAgg);
|
||||||
|
@ -37,7 +37,7 @@ function (angular, _, queryDef) {
|
|||||||
$scope.settingsLinkText = '';
|
$scope.settingsLinkText = '';
|
||||||
$scope.aggDef = _.findWhere($scope.metricAggTypes, {value: $scope.agg.type});
|
$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.pipelineAgg = $scope.agg.pipelineAgg || 'select metric';
|
||||||
$scope.agg.field = $scope.agg.pipelineAgg;
|
$scope.agg.field = $scope.agg.pipelineAgg;
|
||||||
$scope.settingsLinkText = 'Options';
|
$scope.settingsLinkText = 'Options';
|
||||||
|
@ -171,7 +171,7 @@ function (queryDef) {
|
|||||||
var aggField = {};
|
var aggField = {};
|
||||||
var metricAgg = null;
|
var metricAgg = null;
|
||||||
|
|
||||||
if (queryDef.isPipelineAgg(metric)) {
|
if (queryDef.isPipelineAgg(metric.type)) {
|
||||||
if (metric.pipelineAgg && /^\d*$/.test(metric.pipelineAgg)) {
|
if (metric.pipelineAgg && /^\d*$/.test(metric.pipelineAgg)) {
|
||||||
metricAgg = { buckets_path: metric.pipelineAgg };
|
metricAgg = { buckets_path: metric.pipelineAgg };
|
||||||
} else {
|
} else {
|
||||||
|
@ -76,16 +76,16 @@ function (_) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getPipelineOptions: function(metric) {
|
getPipelineOptions: function(metric) {
|
||||||
if (!this.isPipelineAgg(metric)) {
|
if (!this.isPipelineAgg(metric.type)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.pipelineOptions[metric.type];
|
return this.pipelineOptions[metric.type];
|
||||||
},
|
},
|
||||||
|
|
||||||
isPipelineAgg: function(metric) {
|
isPipelineAgg: function(metricType) {
|
||||||
if (metric.type) {
|
if (metricType) {
|
||||||
var po = this.pipelineOptions[metric.type];
|
var po = this.pipelineOptions[metricType];
|
||||||
return po !== null && po !== undefined;
|
return po !== null && po !== undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ function (_) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
var result = [];
|
var result = [];
|
||||||
_.each(targets.metrics, function(metric) {
|
_.each(targets.metrics, function(metric) {
|
||||||
if (!self.isPipelineAgg(metric)) {
|
if (!self.isPipelineAgg(metric.type)) {
|
||||||
result.push({text: self.describeMetric(metric), value: metric.id });
|
result.push({text: self.describeMetric(metric), value: metric.id });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -64,7 +64,7 @@ describe('ElasticQueryDef', function() {
|
|||||||
|
|
||||||
describe('isPipelineMetric', function() {
|
describe('isPipelineMetric', function() {
|
||||||
describe('moving_avg', function() {
|
describe('moving_avg', function() {
|
||||||
var result = QueryDef.isPipelineAgg({ type: 'moving_avg' });
|
var result = QueryDef.isPipelineAgg('moving_avg');
|
||||||
|
|
||||||
it('is pipe line metric', function() {
|
it('is pipe line metric', function() {
|
||||||
expect(result).to.be(true);
|
expect(result).to.be(true);
|
||||||
@ -72,7 +72,7 @@ describe('ElasticQueryDef', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('count', function() {
|
describe('count', function() {
|
||||||
var result = QueryDef.isPipelineAgg({ type: 'count' });
|
var result = QueryDef.isPipelineAgg('count');
|
||||||
|
|
||||||
it('is not pipe line metric', function() {
|
it('is not pipe line metric', function() {
|
||||||
expect(result).to.be(false);
|
expect(result).to.be(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user