-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Threat Hunting Investigations] Show the correct stats in unified fie…
…ld list (#180850) ## Summary Fixes elastic/security-team#9077 Enables correct rendering of top values in the unified field list through a new `dataService` for timeline. This `timelineDataService` is synced with the current timeline's range filter, the selected `indexPattern` and the special `combinedQuery` that timeline is based on. ### Example Two values for `event.category` are present in the current timeline's alerts (`behavior` and `process`): <img width="930" alt="Screenshot 2024-04-15 at 22 06 33" src="https://github.com/elastic/kibana/assets/68591/501ea66e-aaf8-4bc1-b79c-59101eee7ddb"> When filtering for a specific `_id`, only the `process` value is showing and the counts are also correct (`1`): <img width="932" alt="Screenshot 2024-04-15 at 22 06 56" src="https://github.com/elastic/kibana/assets/68591/0871914e-e1b1-4a13-9126-c2523d273009"> ### A wild bugfix appeared While working on this change, I noticed some irregularities that stemmed from a race condition between updates of the filters in redux and in filter manager. In a worst case scenario, this race condition could lead to marking unchanged timelines as changed when opened. Before this fix/refactoring, `filterManager` updates where propagated from a subscription in `QueryBarTimeline`, which is quite deep in the component tree. This resulted in prop drilling (`setFilter`) and bubbling up of changes to where they are handled (`QueryBarTimeline` -> `SearchOrFilter` -> `StatefulSearchOrFilter`). Before: ```mermaid flowchart TD subgraph Redux Store end Store -- filters,setFilters --> StatefulSearchOrFilter StatefulSearchOrFilter -. setFilters(filters) .-> Store StatefulSearchOrFilter -- prop:filters,onFiltersUpdated --> FilterItems --> FilterItem FilterItem -. onRemove .-> FilterItems FilterItems -. onFiltersUpdated(filters) .-> StatefulSearchOrFilter StatefulSearchOrFilter -- prop:setFilters,filters --> SearchOrFilter SearchOrFilter -. setFilters(filters) .-> StatefulSearchOrFilter SearchOrFilter -- prop:setFilters,filters --> QueryBarTimeline QueryBarTimeline -. setFilters(filters) .-> SearchOrFilter QueryBarTimeline ==> |subscribe| TimelineFilterManager TimelineFilterManager -.-> |next| QueryBarTimeline FilterIn ~~~ TimelineFilterManager FilterOut ~~~ TimelineFilterManager DisableFilter ~~~ TimelineFilterManager FilterIn -.-> TimelineFilterManager FilterOut -.-> TimelineFilterManager DisableFilter -.-> TimelineFilterManager ``` In this refactoring, `StatefulSearchOrFilter` is directly subscribing to filter manager changes and `setFilters` has been removed, making `QueryBarTimeline` a proper leaf node. `StatefulSearchOrFilter` now also contains all of the synchronization code between filter manager and redux. After: ```mermaid flowchart TD subgraph Redux Store end Store -- filters,setFilters --> StatefulSearchOrFilter StatefulSearchOrFilter -. setFilters(filters) .-> Store StatefulSearchOrFilter -- prop:filters,onFiltersUpdated --> FilterItems FilterItems -. onFiltersUpdated(filters) .-> StatefulSearchOrFilter StatefulSearchOrFilter -- prop:filters --> SearchOrFilter SearchOrFilter -- prop:setFilters,filters --> QueryBarTimeline StatefulSearchOrFilter ==> |subscribe| TimelineFilterManager TimelineFilterManager -.-> |next| StatefulSearchOrFilter subgraph FilterManager FilterIn ~~~ TimelineFilterManager FilterOut ~~~ TimelineFilterManager DisableFilter ~~~ TimelineFilterManager FilterIn -.-> TimelineFilterManager FilterOut -.-> TimelineFilterManager DisableFilter -.-> TimelineFilterManager end ``` ### - make sure `unifiedComponentsInTimelineEnabled` is enabled before testing this PR ### Checklist - [x] memoize `combinedQueries` - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
216ecd7
commit aa1df6d
Showing
26 changed files
with
244 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.