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

[AggConfigs] Add TopMetrics agg #125936

Merged
merged 2 commits into from
Mar 7, 2022

Conversation

Dosant
Copy link
Contributor

@Dosant Dosant commented Feb 17, 2022

Summary

Adds top_metrics agg to AggConfigs
close #124535

Needed for Lens - #102956

Questions

Q: Keep it enabled in visualize or hide it?

Since top_metrics could also be useful in visualize, I decided to keep it ON. But we can also turn it off similar to how we did to other recently implemented aggs like multi terms, rare terms, etc. Here are some issues I noticed with it:

  1. Unpredictable result for multi-value fields Top Metrics should support multi-value fields like Top Hits does. elasticsearch#82281
  2. Sorting terms agg doesn't work with top-metrics that produce non-numeric results. error: pipeline aggregations may not refer to non-numeric metrics collected by top_metrics

A: Keeping it enabled in visualize

Release notes

Add top metrics aggregation to AggConfigs, Expressions and Visualize

Copy link
Contributor Author

@Dosant Dosant left a comment

Choose a reason for hiding this comment

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

I didn't update any viz editor related configs. Should we exclude top_metrics from all the configs or somehow adjust them properly so vis editors properly supported this new metric?

@@ -43,6 +43,7 @@ export class FieldParamType extends BaseParamType {

this.filterFieldTypes = config.filterFieldTypes || '*';
this.onlyAggregatable = config.onlyAggregatable !== false;
this.scriptable = config.scriptable !== false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Strange... we had this in types and a default scripted = true, but it was never set from config.scriptable 🤔

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Looks pretty good, there is just one thing that might be relevant, added a comment about it.

@Dosant Dosant changed the title basic top metrics [AggConfigs] Add TopMetrics agg Feb 22, 2022
@Dosant Dosant added release_note:enhancement Team:AppServicesSv Feature:Aggregations Aggregation infrastructure (AggConfig, esaggs, ...) v8.2.0 labels Feb 22, 2022
@Dosant Dosant marked this pull request as ready for review February 22, 2022 15:43
@Dosant Dosant requested review from a team as code owners February 22, 2022 15:43
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServicesSv)

@KOTungseth KOTungseth added the ui-copy Review of UI copy with docs team is recommended label Feb 22, 2022
@gchaps
Copy link
Contributor

gchaps commented Feb 22, 2022

@Dosant Can you please add screenshots so we can review the UI copy?

@Dosant
Copy link
Contributor Author

Dosant commented Feb 24, 2022

@elasticmachine merge upstream

@Dosant
Copy link
Contributor Author

Dosant commented Feb 24, 2022

@gchaps, this adds a new aggregation to a service layer that later will be used internally in Lens.
There is an open question if we want to expose this aggregation in visualize as is. Currently, it is exposed and this is how the current copy looks:

Screen Shot 2022-02-24 at 14 36 47

Copy link
Contributor

@gchaps gchaps left a comment

Choose a reason for hiding this comment

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

docslinks service looks good. A few comments on copy.

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Code wise this LGTM.

FYI @ghudgins - this is adding "top metrics" as an option to agg based visualizations:
Screenshot 2022-03-01 at 10 52 45

In general I like the feature it could be slightly confusing though because it's relatively similar to top hits. What do you think?

@ghudgins
Copy link

ghudgins commented Mar 1, 2022

I think it's okay...the agg based visualizations always seem to map to the API directly so this to me doesn't really change the experience too negatively (despite raising a "when to use" question that probably exists already)

@Dosant
Copy link
Contributor Author

Dosant commented Mar 2, 2022

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

expected head sha didn’t match current head ref.

@Dosant Dosant force-pushed the d/2022-02-16-top-metrics-agg branch from 36ac87e to 81bc3ff Compare March 2, 2022 10:43
Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

code LGTM

@Dosant
Copy link
Contributor Author

Dosant commented Mar 7, 2022

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
data 532 534 +2

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
data 2811 2822 +11

Async chunks

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

id before after diff
visDefaultEditor 142.4KB 142.5KB +86.0B

Page load bundle

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

id before after diff
core 295.9KB 296.0KB +63.0B
data 453.1KB 457.9KB +4.8KB
total +4.8KB
Unknown metric groups

API count

id before after diff
data 3408 3419 +11

History

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

@Dosant Dosant requested a review from gchaps March 7, 2022 14:09
Copy link
Contributor

@gchaps gchaps left a comment

Choose a reason for hiding this comment

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

LGTM

@Dosant Dosant merged commit eca203c into elastic:main Mar 7, 2022
lucasfcosta pushed a commit to lucasfcosta/kibana that referenced this pull request Mar 8, 2022
lucasfcosta pushed a commit to lucasfcosta/kibana that referenced this pull request Mar 8, 2022
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 9, 2022
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 125936 or prevent reminders by adding the backport:skip label.

@Dosant Dosant added the backport:skip This commit does not require backporting label Mar 9, 2022
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Aggregations Aggregation infrastructure (AggConfig, esaggs, ...) release_note:enhancement ui-copy Review of UI copy with docs team is recommended v8.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data.search.aggs] Support top metric agg in AggConfigs
9 participants