Skip to content

Commit

Permalink
[Timelion] support one symbol field name
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaanj committed Apr 16, 2021
1 parent bf68a07 commit 671bfae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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' } });
Expand All @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ')';
Expand Down

0 comments on commit 671bfae

Please sign in to comment.