mirror of
https://github.com/grafana/grafana.git
synced 2024-12-02 05:29:42 -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 });
|
||||
if (appliedAgg) {
|
||||
metricName += ' ' + queryDef.describeMetric(appliedAgg);
|
||||
|
@ -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';
|
||||
|
@ -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 {
|
||||
|
@ -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 });
|
||||
}
|
||||
});
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user