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

[Discover] Update unified histogram to use Lens #143117

Merged

Conversation

davismcphee
Copy link
Contributor

@davismcphee davismcphee commented Oct 11, 2022

Summary

This PR updates Discover and Unified Histogram to use Lens for the histogram chart, and removes Discover as a Lens dependency:
discover_lens

Note that there are some additional changes to make in followup PRs before this will be ready for solutions adoption:

  • Add the ability for Unified Histogram to support manually refetching in addition to auto refetching.
  • Currently Unified Histogram watches for changes to the query, filters, and time range. We will need to update this so those dependencies are passed as props instead.
  • It would be helpful to add some usage documentation to Unified Histogram to help other teams implement it in their projects.

A la carte deployment: https://davismcphee-pr-143117-enhancement-unified-histogram-lens.kbndev.co.

Flaky test runs:

Resolves #143108.
Resolves #142390.

Checklist

For maintainers

@davismcphee davismcphee added release_note:enhancement Feature:Discover Discover Application Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. v8.6.0 labels Oct 11, 2022
@davismcphee davismcphee self-assigned this Oct 11, 2022
@github-actions
Copy link
Contributor

Documentation preview:

@davismcphee davismcphee force-pushed the enhancement-unified-histogram-lens branch 2 times, most recently from 17dd348 to a08d947 Compare October 18, 2022 02:25
@davismcphee davismcphee force-pushed the enhancement-unified-histogram-lens branch from 477f1d4 to 838445c Compare November 2, 2022 17:21
@1Copenut
Copy link
Contributor

@davismcphee I brought this question to the EUI team's weekly meetup today. We recommend using the titles that appear on hover automatically, and adding the prop textWrap="wrap" to your instance of EuiSelectableOptionsList. It will cause the longer list item names to wrap to a second row, but will be a more inclusive solution than a tooltip for the widest number of users.

@davismcphee
Copy link
Contributor Author

@davismcphee I brought this question to the EUI team's weekly meetup today. We recommend using the titles that appear on hover automatically, and adding the prop textWrap="wrap" to your instance of EuiSelectableOptionsList. It will cause the longer list item names to wrap to a second row, but will be a more inclusive solution than a tooltip for the widest number of users.

@1Copenut Thanks for looking into this. Unless I'm misunderstanding something, it seems like this suggestion might not be possible, at least the text wrapping part of it. The component we're using here is EuiComboBox which doesn't seem to support that option. I considered rendering custom options with text wrapping since it supports a renderOption prop, but the docs forbid that due to virtualization: https://elastic.github.io/eui/#/forms/combo-box#option-rendering.

Copy link
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

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

Awesome work! Happy to see the new chart + breakdown capabilities 👍

if (storage) {
services = { ...services, storage };
}
(services.data.query.queryString.getDefaultQuery as jest.Mock).mockReturnValue({
Copy link
Contributor

Choose a reason for hiding this comment

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

We could add it inside createDiscoverServicesMock

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with this, but I tried to update quickly and it broke some unrelated tests that were expecting getDefaultQuery to return undefined. I think it's a good cleanup task though, just would prefer to save for another PR.

@@ -124,7 +124,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"osquery-saved-query": "7b213b4b7a3e59350e99c50e8df9948662ed493a",
"query": "4640ef356321500a678869f24117b7091a911cb6",
"sample-data-telemetry": "8b10336d9efae6f3d5593c4cc89fb4abcdf84e04",
"search": "d26771bcf7cd271162aab3a610b75249631ef6b1",
"search": "b212646cedccdfb0f8504426f72d1e087c4bab7c",
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious how this change was introduced?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are hashes of saved object mappings to alert the core team when the mappings are updated. The hash got updated once when we added breakdownField to the PR, but it got updated again when I merged main recently since we also added usesAdHocDataView. Basically I just needed to update it again to match the latest hash.

@1Copenut
Copy link
Contributor

1Copenut commented Dec 1, 2022

The component we're using here is EuiComboBox which doesn't seem to support that option. I considered rendering custom options with text wrapping since it supports a renderOption prop, but the docs forbid that due to virtualization: https://elastic.github.io/eui/#/forms/combo-box#option-rendering.

The EUI team could look at adding a prop to define beginning/middle/end truncation. I'll open a feature issue for it and link it here. This feels like the best alternative we can offer given the boundaries of same height for virtualization.

elastic/eui#6448

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

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

ML edits LGTM

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
discover 446 442 -4
unifiedHistogram 38 49 +11
total +7

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
discover 81 82 +1
savedSearch 44 45 +1
unifiedHistogram 29 15 -14
total -12

Async chunks

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

id before after diff
discover 413.7KB 418.2KB +4.5KB
lens 1.3MB 1.3MB -25.0B
unifiedHistogram 13.6KB 33.9KB +20.3KB
total +24.8KB

Page load bundle

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

id before after diff
discover 27.9KB 28.0KB +53.0B
lens 29.6KB 29.8KB +139.0B
savedSearch 5.2KB 5.2KB +64.0B
unifiedHistogram 17.4KB 4.8KB -12.6KB
total -12.4KB

Saved Objects .kibana field count

Every field in each saved object type adds overhead to Elasticsearch. Kibana needs to keep the total field count below Elasticsearch's default limit of 1000 fields. Only specify field mappings for the fields you wish to search on or query. See https://www.elastic.co/guide/en/kibana/master/saved-objects-service.html#_mappings

id before after diff
search 23 24 +1
Unknown metric groups

API count

id before after diff
discover 98 100 +2
savedSearch 44 45 +1
unifiedHistogram 56 52 -4
total -1

ESLint disabled in files

id before after diff
osquery 1 2 +1

ESLint disabled line counts

id before after diff
discover 39 40 +1
enterpriseSearch 19 21 +2
fleet 59 65 +6
osquery 109 115 +6
securitySolution 443 449 +6
unifiedHistogram 1 2 +1
total +22

Total ESLint disabled count

id before after diff
discover 40 41 +1
enterpriseSearch 20 22 +2
fleet 68 74 +6
osquery 110 117 +7
securitySolution 520 526 +6
unifiedHistogram 1 2 +1
total +23

History

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

cc @davismcphee

@davismcphee davismcphee merged commit d1de864 into elastic:main Dec 5, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Dec 5, 2022
@davismcphee davismcphee deleted the enhancement-unified-histogram-lens branch December 5, 2022 13:43
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:Discover Discover Application release_note:enhancement Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. v8.7.0
Projects
None yet