From 671bfae27f8c4eacbdc1b5ddbef215c9d3ba20f0 Mon Sep 17 00:00:00 2001 From: Dzmitry Tamashevich Date: Fri, 16 Apr 2021 14:57:45 +0300 Subject: [PATCH] [Timelion] support one symbol field name --- .../vis_type_timelion/server/series_functions/es/es.test.js | 4 ++++ .../server/series_functions/es/lib/create_date_agg.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/plugins/vis_type_timelion/server/series_functions/es/es.test.js b/src/plugins/vis_type_timelion/server/series_functions/es/es.test.js index 5fc33f2b7f77a..3ace745604660 100644 --- a/src/plugins/vis_type_timelion/server/series_functions/es/es.test.js +++ b/src/plugins/vis_type_timelion/server/series_functions/es/es.test.js @@ -131,6 +131,7 @@ describe('es', () => { 'sum:\\:beer', 'percentiles:\\:\\:bytes:1.2,1.3,2.7', 'percentiles:\\:bytes\\:123:20.0,50.0,100.0', + 'percentiles:a:2', ]; agg = createDateAgg(config, tlConfig, emptyScriptedFields); expect(agg.time_buckets.aggs['sum(beer)']).toEqual({ sum: { field: 'beer' } }); @@ -148,6 +149,9 @@ describe('es', () => { expect(agg.time_buckets.aggs['percentiles(:bytes:123)']).toEqual({ percentiles: { field: ':bytes:123', percents: [20.0, 50.0, 100.0] }, }); + expect(agg.time_buckets.aggs['percentiles(a)']).toEqual({ + percentiles: { field: 'a', percents: [2] }, + }); }); test('adds a scripted metric agg for each scripted metric', () => { diff --git a/src/plugins/vis_type_timelion/server/series_functions/es/lib/create_date_agg.js b/src/plugins/vis_type_timelion/server/series_functions/es/lib/create_date_agg.js index d3aaf6e772d84..129fdf7071d3e 100644 --- a/src/plugins/vis_type_timelion/server/series_functions/es/lib/create_date_agg.js +++ b/src/plugins/vis_type_timelion/server/series_functions/es/lib/create_date_agg.js @@ -42,7 +42,7 @@ export default function createDateAgg(config, tlConfig, scriptedFields) { }, }; } else if (metricName && metricArgs) { - const splittedArgs = metricArgs.split(/(.+[^\\]):/).filter(Boolean); + const splittedArgs = metricArgs.split(/(.*[^\\]):/).filter(Boolean); const field = splittedArgs[0].replace(/\\:/g, ':'); const percentArgs = splittedArgs[1]; const metricKey = metricName + '(' + field + ')';