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

[Lens] Rank top values by custom metric #134811

Merged
merged 20 commits into from
Jul 6, 2022

Conversation

mbondyra
Copy link
Contributor

@mbondyra mbondyra commented Jun 21, 2022

Summary

Fixes #133991.
Screenshot 2022-07-04 at 10 19 59
Screenshot 2022-07-04 at 10 20 05
Screenshot 2022-07-04 at 10 20 12

  • added new orderBy option: custom
  • added new param to terms column : orderAgg
  • refactored ReferenceEditor to also be able to edit inline columns, not just referenced ones
  • refactored metrics paramEditor to accept also inlined columns and not referenced by columnId inside layer
    Extra fixes:
  • Fix: ___records___ displayed as Records when moving from count to another operation type

Screenshot 2022-06-27 at 11 13 56

  • Fix: array last value option should impossible to select when last value is a referenced operation.

Screenshot 2022-06-27 at 11 15 56

  • Fix: correct all the dimension panel elements to occupy the full width for mobile, eg this one before fix:

Screenshot 2022-06-29 at 09 43 29

Checklist

@mbondyra mbondyra added release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Lens v8.4.0 labels Jun 21, 2022
@mbondyra mbondyra force-pushed the lens/rank_by_custom_metric branch 7 times, most recently from 9f587d4 to 474db68 Compare June 24, 2022 15:52
@mbondyra mbondyra changed the title [Lens] WIP Rank top values by custom metric [Lens] Rank top values by custom metric Jun 24, 2022
@mbondyra mbondyra force-pushed the lens/rank_by_custom_metric branch 12 times, most recently from 68f1d2a to 68d2a55 Compare June 28, 2022 08:51
@mbondyra mbondyra marked this pull request as ready for review June 28, 2022 10:30
@mbondyra mbondyra requested a review from a team as a code owner June 28, 2022 10:30
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors)

@mbondyra mbondyra force-pushed the lens/rank_by_custom_metric branch 3 times, most recently from b7a7869 to ce2b3df Compare June 28, 2022 12:19
@mbondyra
Copy link
Contributor Author

mbondyra commented Jul 3, 2022

@elasticmachine merge upstream

@mbondyra mbondyra requested a review from a team as a code owner July 4, 2022 08:42
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.

This works great and is an amazing addition. I have only found one bug.

I have created a chart like this
image

I am using a custom rank by count. When I click on the chart to create a filter, the filter is not created and I see the following error on the console
image

@flash1293
Copy link
Contributor

Reviewed the changes since last time and this still looks good to me, thanks! ABout the bug @stratoula found - it's probably related to the redux toolkit change detection thingy again beause in


the redux managed object is passed directly into the agg config logic.

It's actually pretty cool it's catching this because it could cause weird behavior (saved object suddenly has another property schema). I wonder whether we can get typescript to flag these cases (maybe enforcing immutable types using a DeepReadonly style generic type for the state types), but it's definitely out of scope for this PR

@flash1293
Copy link
Contributor

Actually I think it's happening somewhere else and it might be harder to fix in general... We put the data table into the redux store (activeData), which causes it to get frozen, but then we pass the same data table to the filter click handler which apparently tries to mutate it. I guess it should be fixed on the app services side - passed in agg params shouldn't get mutated, that's totally unexpected

@flash1293
Copy link
Contributor

Deep cloning the params here makes it work:

@mbondyra mbondyra requested a review from a team as a code owner July 5, 2022 08:45
@mbondyra
Copy link
Contributor Author

mbondyra commented Jul 5, 2022

@stratoula and @flash1293 thank you for finding the bug and for the investigation! I've fixed it with suggested solution, @stratoula please recheck when you have a moment :)

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.

Thanx Marta and Joe! Now it works fine! LGTM

Copy link
Contributor

@MichaelMarcialis MichaelMarcialis left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together, @mbondyra! This looks great. I'm leaving you a handful of small comments/suggestions below. Assuming those get addressed, this looks good from my perspective. Approving now so I don't hold you up.

@@ -0,0 +1,3 @@
.lnsInnerIndexPattern__inlineRow {
min-width: 96px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, I hadn't considered the "Percentile ranks value" input when putting together the mockups. I think we'll need to increase the min-width here in order to ensure the prepended labels are the same width (or alternatively come up with a shorter label than "Percentile ranks value").

image

Suggested change
min-width: 96px;
min-width: 144px;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That unfortunately has the other effect when we don't use percentile ranks - it takes too much space...

Screenshot 2022-07-05 at 23 15 22

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. What about a shorter name for "Percentile ranks value"? For example, would simply "Percentile rank" work? Then we could adjust the label min-width to be equal to the largest of the labels.

Copy link
Contributor

@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.

Thanks for the agg config change! lgtm!

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #36 / endpoint When on the Endpoint Policy Details Page "after all" hook in "When on the Endpoint Policy Details Page"
  • [job] [logs] FTR Configs #36 / endpoint When on the Endpoint Policy Details Page "before all" hook in "When on the Endpoint Policy Details Page"

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
lens 917 923 +6

Async chunks

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

id before after diff
charts 78.6KB 78.6KB +26.0B
expressionHeatmap 80.9KB 80.9KB +26.0B
lens 1.2MB 1.2MB +4.2KB
total +4.2KB

Page load bundle

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

id before after diff
data 418.7KB 418.7KB +15.0B

History

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

@mbondyra mbondyra merged commit f0965a3 into elastic:main Jul 6, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jul 6, 2022
@mbondyra mbondyra deleted the lens/rank_by_custom_metric branch July 6, 2022 12:37
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:Lens release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] Custom rank agg for top values / pick hidden metrics
8 participants