Elasticsearch: Add Moving Function Pipeline Aggregation (#28131)

* Elasticsearch: Add Moving Function Pipeline Aggregation

* Removing support for moving average in 7.x

* Fixing getMetricAggTypes to handle undefined esVersion

* Adding moving_fn to go code

* Update public/app/plugins/datasource/elasticsearch/metric_agg.ts

Co-authored-by: Giordano Ricci <grdnricci@gmail.com>

* Adding test for esversion 70

* Removing default value for script, adding placeholder instead

* Fixing formatting

* Adding code for handling missing or obsolete aggregations

Co-authored-by: Giordano Ricci <grdnricci@gmail.com>
This commit is contained in:
Chris Cowan
2020-11-11 10:42:28 -07:00
committed by GitHub
parent af8589a4ba
commit 4ed7612e57
5 changed files with 65 additions and 6 deletions

View File

@@ -162,8 +162,21 @@ describe('ElasticQueryDef', () => {
});
describe('using esversion 5', () => {
const metricAggTypes = queryDef.getMetricAggTypes(5);
test('should get pipeline aggs', () => {
expect(queryDef.getMetricAggTypes(5).length).toBe(15);
expect(metricAggTypes.length).toBe(15);
});
});
describe('using esversion 70', () => {
const metricAggTypes = queryDef.getMetricAggTypes(70);
test('should get pipeline aggs', () => {
expect(metricAggTypes.length).toBe(15);
});
test('should get pipeline aggs with moving function', () => {
expect(metricAggTypes.some(m => m.value === 'moving_fn')).toBeTruthy();
});
test('should get pipeline aggs without moving average', () => {
expect(metricAggTypes.some(m => m.value === 'moving_avg')).toBeFalsy();
});
});
});