Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Timelion] Fixes bug with escape colons in field names in the metric/split parameter #96770

Merged
merged 12 commits into from
Apr 20, 2021

Conversation

dimaanj
Copy link
Contributor

@dimaanj dimaanj commented Apr 12, 2021

Closes #95954

Summary

  • added support for colons in field names for metric
  • for metric with field name :te:st:1

B1452ED0-D583-4D8A-8233-9F9A7427BCEC

  • for split with field name :te:st1:

7793A739-C02E-4860-9A1D-9B75242A4EAC

@kibanamachine
Copy link
Contributor

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@alexwizp alexwizp requested review from alexwizp and stratoula April 12, 2021 10:48
@alexwizp alexwizp added Feature:Timelion Timelion app and visualization v7.13.0 Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 labels Apr 12, 2021
@@ -30,7 +31,7 @@ export default function createDateAgg(config, tlConfig, scriptedFields) {

dateAgg.time_buckets.aggs = {};
_.each(config.metric, function (metric) {
metric = metric.split(':');
metric = metric.split(/:(.+)/).slice(0, OPERANDS_NUMBER);
Copy link
Contributor

@alexwizp alexwizp Apr 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the 'percentiles' aggregation. I see that in code below that we are getting third item from the metric array.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved

dateAgg.time_buckets.aggs[metricName][metric[0]] = buildAggBody(metric[1], scriptedFields);
if (metric[0] === 'percentiles' && metric[2]) {
let percentList = metric[2].split(',');
dateAgg.time_buckets.aggs[metricName][metric[0]] = buildAggBody(field, scriptedFields);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if we do it a little bit obvious. I see we are dealing with 3 cases.

const [metricName, metricArgs] = metric.split(/:(.+)/);
   
if (metricName === 'count') {

} else if (metricName === 'percentiles') {

} else if (metricName, metricArgs){

}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh... sorry, I see we need

dateAgg.time_buckets.aggs[metricName] = {};
dateAgg.time_buckets.aggs[metricName][metric[0]] = buildAggBody(field, scriptedFields);

for percentiles too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, it's cleaned up from array indexes at least

@alexwizp alexwizp self-requested a review April 15, 2021 08:02
@stratoula
Copy link
Contributor

@elasticmachine merge upstream

@stratoula
Copy link
Contributor

Jenkins test this

'cardinality::sample',
'sum::beer',
'percentiles::bytes:1',
'percentiles:::bytes:1.2,1.3,2.7',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice ❤️

(config.metric || []).forEach((metric) => {
const metricBody = {};
const [metricName, metricArgs] = metric.split(/:(.+)/);
if (metricName === 'count') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that this is how it was before but do you want to use instead of count and percentiles the METRIC_TYPES.COUNT and METRIC_TYPES.PERCENTILES from the data plugin?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@alexwizp
Copy link
Contributor

needs more work, suggestions are not working fine with fields started from :

@stratoula
Copy link
Contributor

stratoula commented Apr 15, 2021

Yes and split also doesn't work
image

@stratoula
Copy link
Contributor

@elasticmachine merge upstream

@stratoula stratoula marked this pull request as ready for review April 19, 2021 07:47
@stratoula stratoula requested a review from a team April 19, 2021 07:47
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@stratoula stratoula changed the title [Timelion] Cannot escape colons in field names in the metric parameter [Timelion] Fixes bug with escape colons in field names in the metric/split parameter Apr 19, 2021
Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Dima, it seems to work fine now 👏 LGTM

@alexwizp can you also check it again?

@dimaanj dimaanj self-assigned this Apr 19, 2021
import { buildAggBody } from './agg_body';
import { search } from '../../../../../../plugins/data/server';
import { METRIC_TYPES } from '../../../../../data/common/search/aggs/metrics/index';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong import. Please replace to '../../../../../data/server'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved

const metricBody = {};
const [metricName, metricArgs] = metric.split(/:(.+)/);
console.log('METRIC_TYPES.COUNT', METRIC_TYPES.COUNT);
console.log('METRIC_TYPES.PERCENTILES', METRIC_TYPES.PERCENTILES);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmitriynj please remove the console.logs :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, done

@stratoula
Copy link
Contributor

Jenkins test this

Copy link
Contributor

@alexwizp alexwizp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
visTypeTimelion 69.3KB 69.2KB -43.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
visTypeTimelion 24.2KB 24.4KB +154.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @dmitriynj

@dimaanj dimaanj merged commit 4faff46 into elastic:master Apr 20, 2021
dimaanj added a commit to dimaanj/kibana that referenced this pull request Apr 20, 2021
…split parameter (elastic#96770)

* [Timelion] add colons support in field names for metric

* [Timelion] support percent for metric

* [Timelion] get rid of array indexes

* [Timelion] get rid of lodash methods

* [Timelion] support colons in split. fix expression suggestions

* [Timelion] escape colons for metric

* [Timelion] use metric types common constants

* [Timelion] support one symbol field name

* [Timelion] resolve duplicate imports

* [Timelion] remove console logs

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
dimaanj added a commit that referenced this pull request Apr 20, 2021
…split parameter (#96770) (#97606)

* [Timelion] add colons support in field names for metric

* [Timelion] support percent for metric

* [Timelion] get rid of array indexes

* [Timelion] get rid of lodash methods

* [Timelion] support colons in split. fix expression suggestions

* [Timelion] escape colons for metric

* [Timelion] use metric types common constants

* [Timelion] support one symbol field name

* [Timelion] resolve duplicate imports

* [Timelion] remove console logs

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@samuelkampa
Copy link

@dmitriynj , @alexwizp , & @stratoula : Thanks for all your hard work on this! Our team is stoked about the change. Can't wait for the next release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Timelion Timelion app and visualization release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.13.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timelion: Cannot escape colons in field names in the metric parameter
6 participants