-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Logs+] Implement Logs Dataset selector #159907
[Logs+] Implement Logs Dataset selector #159907
Conversation
…-ref HEAD~1..HEAD --fix'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few final comments below. Thanks for following up on the previous ones.
One thing I noticed during testing is that a user might want to reload the list of integrations or the list of uncategorized datasets even when no error occured before. During testing, for example, I started a shipper in the background but its new data stream didn't show up until I navigated away and back. Any idea how we could allow triggering a reload without cluttering the UI?
...gins/discover_log_explorer/public/components/dataset_selector/state_machine/state_machine.ts
Show resolved
Hide resolved
...gins/discover_log_explorer/public/components/dataset_selector/state_machine/state_machine.ts
Outdated
Show resolved
Hide resolved
...gins/discover_log_explorer/public/components/dataset_selector/state_machine/state_machine.ts
Show resolved
Hide resolved
x-pack/plugins/discover_log_explorer/public/components/dataset_selector/utils.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/discover_log_explorer/public/components/dataset_selector/utils.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/discover_log_explorer/public/hooks/use_intersection_ref.ts
Show resolved
Hide resolved
x-pack/plugins/discover_log_explorer/public/components/dataset_selector/dataset_selector.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/discover_log_explorer/public/components/dataset_selector/dataset_selector.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/discover_log_explorer/public/components/dataset_selector/constants.tsx
Outdated
Show resolved
Hide resolved
x-pack/test/functional/apps/discover_log_explorer/customization.ts
Outdated
Show resolved
Hide resolved
…n.ts Co-authored-by: Felix Stürmer <[email protected]>
Yes, maybe my testing procedure was not exactly representative of normal usage. Once we have the selection state restoration in place a reload will be less jarring anyway. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work overall, very well done 👏
Aside from the great readability I was pleasantly surprised to see that you managed to not increase the size of any other bundle in any significant way. 🎉
As agreed upon via other channels, there are few high-priority follow-ups that we will want to implement next:
- [Log Explorer] Restore dataset selector state from URL #160425
- [Log Explorer] Show message column by default #160422
- [Log Explorer] Missing test suite for DatasetSelector in log-explorer profile #160627
The merge of this PR will unblock the implementation of
- [Log Explorer] Add filter controls customization point #158561
- [Log Explorer] Add specialized locators #158382
Thank you for all the effort and care you invested into this!
@@ -28,6 +28,7 @@ export const storybookAliases = { | |||
dashboard: 'src/plugins/dashboard/.storybook', | |||
data: 'src/plugins/data/.storybook', | |||
discover: 'src/plugins/discover/.storybook', | |||
discover_log_explorer: 'x-pack/plugins/discover_log_explorer/.storybook', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we also add it to .buildkite/scripts/steps/storybooks/build_and_upload.ts
as recently documented in #160473?
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
async chunk count
ESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
## 📓 Summary Closes #160425 After the [first implementation of the log-explorer profile](#159907), we wanted to restore the selection of the dataset for a user when landing on the Discover log-explorer profile. Since we create an ad-hoc data view for Discover starting from the dataset details, we needed to develop a system for intercepting the `index` query parameter (which is used by Discover as the source of truth for restoring a data view), create our ad-hoc data view and store in the URL an encoded ID with the required details to restore the selection. The following video shows the user journey for: - Landing on the log-explorer profile with no index param, nothing to restore and fallback to All log datasets. - Landing on the log-explorer profile invalid index param, notify about failure and fallback to All log datasets. - Select a different dataset, applies the new data view and update the URL. When the URL is accessed directly, restore and initialize the data view for the selection. - Navigate back and forth in the browser history, restoring the selection and data view on `index` param changes. https://github.com/elastic/kibana/assets/34506779/37a212ee-08e4-4e54-8e42-1d739c38f164 ## 💡 Reviewer hints To have better control over the page selection and the restore process, we prepared the DatasetSelector component for [being controlled by the parent component](#160971). Having that ready, we now implemented a new top-level state machine with the following responsibilities: - Re-initialize (decompress/decode) the dataset selection from the `index` query params. - Derive and set into Discover state a new ad-hoc data view. - Keep track of new dataset selection changes and update the URL state and the current data view. <img width="1224" alt="log-explorer-machine" src="https://github.com/elastic/kibana/assets/34506779/67e3ff17-dc3f-4dcf-b6c0-f40dbbea2d44"> We found a race condition between the Discover URL initialization + data view initialization against the log-explorer profile customizations being applied. To guarantee we correctly initialize the state machine and restore the selection before Discover goes through its initialization steps, we need to wait for the customization service to exist in Discover so that also the customization callbacks are successfully invoked. --------- Co-authored-by: Marco Antonio Ghiani <[email protected]> Co-authored-by: kibanamachine <[email protected]>
## 📓 Summary Closes elastic#160425 After the [first implementation of the log-explorer profile](elastic#159907), we wanted to restore the selection of the dataset for a user when landing on the Discover log-explorer profile. Since we create an ad-hoc data view for Discover starting from the dataset details, we needed to develop a system for intercepting the `index` query parameter (which is used by Discover as the source of truth for restoring a data view), create our ad-hoc data view and store in the URL an encoded ID with the required details to restore the selection. The following video shows the user journey for: - Landing on the log-explorer profile with no index param, nothing to restore and fallback to All log datasets. - Landing on the log-explorer profile invalid index param, notify about failure and fallback to All log datasets. - Select a different dataset, applies the new data view and update the URL. When the URL is accessed directly, restore and initialize the data view for the selection. - Navigate back and forth in the browser history, restoring the selection and data view on `index` param changes. https://github.com/elastic/kibana/assets/34506779/37a212ee-08e4-4e54-8e42-1d739c38f164 ## 💡 Reviewer hints To have better control over the page selection and the restore process, we prepared the DatasetSelector component for [being controlled by the parent component](elastic#160971). Having that ready, we now implemented a new top-level state machine with the following responsibilities: - Re-initialize (decompress/decode) the dataset selection from the `index` query params. - Derive and set into Discover state a new ad-hoc data view. - Keep track of new dataset selection changes and update the URL state and the current data view. <img width="1224" alt="log-explorer-machine" src="https://github.com/elastic/kibana/assets/34506779/67e3ff17-dc3f-4dcf-b6c0-f40dbbea2d44"> We found a race condition between the Discover URL initialization + data view initialization against the log-explorer profile customizations being applied. To guarantee we correctly initialize the state machine and restore the selection before Discover goes through its initialization steps, we need to wait for the customization service to exist in Discover so that also the customization callbacks are successfully invoked. --------- Co-authored-by: Marco Antonio Ghiani <[email protected]> Co-authored-by: kibanamachine <[email protected]>
📓 Summary
Closes https://github.com/elastic/observability-dev/issues/2655
This PR introduces a customized log consumption experience in the Discover plugin. By leveraging the new
discover_log_explorer
plugin and utilizing thediscover.customize
functionality, we have curated a more tailored user experience.The key feature of this implementation is the
DatasetSelector
component, which replaces the original DiscoverDataViewPicker
. It handles the retrieval, rendering, and navigation of integrations and data streams related to logs, providing an improved user interface.This PR involves significant development efforts, including the creation of the
discover_log_explorer
plugin, implementation of services, state machines, custom hooks, and enhancements to presentational components. The following overview will help reviewers understand the responsibilities of each component in this implementation.demo-selector-fhd.mov
DatasetsService & DatasetsClient
The DatasetsService is introduced, a crucial component that mediates access to the newly implemented DatasetsClient. During the plugin's lifecycle, the DatasetsService exposes a client property through its start() method, providing convenient access to a DatasetsClient instance.
The DatasetsClient is responsible for abstracting the data fetching process for two endpoints: the integrations endpoint and the data streams listing endpoint. These endpoints are utilized to populate the selector options in the user interface. To facilitate this, the DatasetsClient exposes the findIntegrations and findDatasets methods, which handle the respective data fetching.
Discover Customization
The critical part of this work consists of where the customization is applied.
Inside the
public/plugin.tsx
, we lazy load and create, injecting the required dependencies, theCustomDatasetSelector
, which already encapsulates all the logic required to make the selector work with the external APIs.We kept separating the data fetching logic from how the selector works, and all the data and events are passed into the UI component with properties.
Data fetching state machines & custom hooks
To handle the data fetching of integrations and unmanaged data streams, we created two different state machines to separately handle the related action for each dataset, such as remote search, in-memory search, error handling etc.
Integration machine and useIntegrations
The integrations state machine handles automatic data fetching of the resources and additionally provides transitions for loading more integrations, searching integrations by HTTP request, searching locally into integration streams, and all the related loading and error handling states.
It is then interpreted inside the
useIntegrations
custom hook, which exposes the fetched data and handlers for all the above-mentioned actions.Datasets machine and useDatasets
Similar to the integrations state machine, but simplified since the data streams search can only happen with HTTP requests and there is no pagination that requires to handle the load of more entries.
It is interpreted inside the
useDatasets
custom hook, which also exposes the fetched data and handlers for the available actions.DatasetSelector
The
DatasetSelector
component contains all the logic that manages the navigation and searches across the different panels that render integrations, integrations' streams or unmanaged streams.As the datasets come from different APIs or are performed in-memory, the search work follow this logic:
EuiContextMenu
), the search is done with an HTTP request.EuiContextMenu
), the search is done in-memory, filtering and sorting directly in the client.EuiContextMenu
), the search is done again with an HTTP request.To handle these possible user journeys correctly without side effects, we created another state machine and exposed its actions with an internal
useDatasetSelector
custom hook.Next steps
This component will change quite a lot until we won't get to a final design. As soon as a first solid mvp is defined for production, a complete test for the component will be implemented, among with a more generic functional test for the core customization features.