Skip to content

Comments

[Security Solution] Replace use_sourcerer_data_view#216997

Merged
lgestc merged 41 commits intoelastic:mainfrom
lgestc:replace_use_sourcerer_data_view
Apr 28, 2025
Merged

[Security Solution] Replace use_sourcerer_data_view#216997
lgestc merged 41 commits intoelastic:mainfrom
lgestc:replace_use_sourcerer_data_view

Conversation

@lgestc
Copy link
Contributor

@lgestc lgestc commented Apr 3, 2025

Summary

This PR replaces useSourcererDataView hook / other apis based on the sourcerer component with
the new code using unified data view picker. (behind a feature flag for now, with the intention of enabling it before 9.1 if we make it on time).

Testing

Set the following flag, then you should see the new picker, at least on the pages with global header.
xpack.securitySolution.enableExperimental: ['newDataViewPickerEnabled']

The most important thing: Not setting the feature flag, you should be able to use the previous sourcerer component with no issues.

Optional (this is WIP):

On some pages, changing the view using that picker should result in changes to data loaded (inspect the queries made to see if the correct index is picked).

@lgestc lgestc requested review from a team as code owners April 3, 2025 11:35
Comment on lines +84 to +86
<DataViewPicker
scope={sourcererScope}
disabled={sourcererScope === DataViewManagerScopeName.detections}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

disabling the picker on alerts page, right now it is not possible to change the data view anyway since the pattern is not passed to the server side

@lgestc lgestc requested review from a team as code owners April 3, 2025 12:35
@lgestc
Copy link
Contributor Author

lgestc commented Apr 3, 2025

replacing most of the useSourcererDataView here :) FYI @christineweng @michaelolo24

@lgestc lgestc force-pushed the replace_use_sourcerer_data_view branch from 8a566ec to 74ab922 Compare April 7, 2025 07:55
@lgestc lgestc requested review from a team as code owners April 7, 2025 07:55
@lgestc lgestc requested review from hop-dev and maximpn April 7, 2025 07:55
@lgestc lgestc marked this pull request as draft April 7, 2025 07:56
@elastic elastic deleted a comment from elasticmachine Apr 10, 2025
@lgestc lgestc added Feature:Sourcerer Team:Threat Hunting:Investigations Security Solution Threat Hunting Investigations Team labels Apr 15, 2025
Copy link
Contributor

@angorayc angorayc left a comment

Choose a reason for hiding this comment

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

Great job, well done! Thanks for implementing this @lgestc
Some issues found after applying a temporary data view. Please check #216997 (comment) and see if you are able to reproduce them.

@lgestc
Copy link
Contributor Author

lgestc commented Apr 23, 2025

Great job, well done! Thanks for implementing this @lgestc Some issues found after applying a temporary data view. Please check #216997 (comment) and see if you are able to reproduce them.

thank you Angela, I will take a look & fix this somehow

Update: the first problem is by design and will be mitigated somehow, in short - we dont want to allow saving timelines with adhoc dataviews. Possible solution would be to embed the pattern into the timeline, or force the data view save first... it will be addressed somehow in the future PRs. Not sure how yet.

2nd problem - most likely something invalidates the data view cache on the client side, I will try to find out what it is in this specific path. We had similar issue in some other flows where data view cache would be cleared manually in some useEffect context.

FYI @michaelolo24 @christineweng

@lgestc lgestc requested review from a team as code owners April 24, 2025 07:50
@lgestc lgestc requested a review from angorayc April 24, 2025 07:50
@lgestc
Copy link
Contributor Author

lgestc commented Apr 24, 2025

Great job, well done! Thanks for implementing this @lgestc Some issues found after applying a temporary data view. Please check #216997 (comment) and see if you are able to reproduce them.

Thanks @angorayc !

Fixed the temp issue #2 https://github.com/elastic/kibana/pull/216997/files#diff-64fbab14826f73c2214e6c2d9022011fe8cc2ee6c169381865b9e70f58c01e5bL123 , the toast warning when saving timeline will remain the way it is for now.

@elastic elastic deleted a comment from elasticmachine Apr 24, 2025
Copy link
Contributor

@michaelolo24 michaelolo24 left a comment

Choose a reason for hiding this comment

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

Nice work!

@davismcphee davismcphee removed the request for review from a team April 25, 2025 03:45
Copy link
Contributor

@angorayc angorayc left a comment

Choose a reason for hiding this comment

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

Screenshot 2025-04-28 at 10 01 35

Thanks for the fix, @lgestc , looking good!
Found a typo in the error message at the bottom right corner, "Persting" should be Persisting.

@lgestc lgestc enabled auto-merge (squash) April 28, 2025 10:44
@lgestc lgestc merged commit a521146 into elastic:main Apr 28, 2025
9 checks passed
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 7341 7342 +1

Async chunks

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

id before after diff
observability 1.3MB 1.3MB +36.0B
securitySolution 9.1MB 9.1MB +6.2KB
triggersActionsUi 1.4MB 1.4MB +36.0B
total +6.3KB
Unknown metric groups

ESLint disabled in files

id before after diff
securitySolution 86 87 +1

ESLint disabled line counts

id before after diff
securitySolution 587 586 -1

History

akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request May 29, 2025
## Summary

This PR replaces `useSourcererDataView` hook / other apis based on the
sourcerer component with
the new code using unified data view picker. (behind a feature flag for
now, with the intention of enabling it before 9.1 if we make it on
time).

## Testing

Set the following flag, then you should see the new picker, at least on
the pages with global header.
`xpack.securitySolution.enableExperimental:
['newDataViewPickerEnabled']`

**The most important thing**: Not setting the feature flag, you should
be able to use the previous sourcerer component with no issues.

Optional (this is WIP):

On some pages, changing the view using that picker should result in
changes to data loaded (inspect the queries made to see if the correct
index is picked).

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
christineweng pushed a commit to christineweng/kibana that referenced this pull request Jun 6, 2025
This PR replaces `useSourcererDataView` hook / other apis based on the
sourcerer component with
the new code using unified data view picker. (behind a feature flag for
now, with the intention of enabling it before 9.1 if we make it on
time).

Set the following flag, then you should see the new picker, at least on
the pages with global header.
`xpack.securitySolution.enableExperimental:
['newDataViewPickerEnabled']`

**The most important thing**: Not setting the feature flag, you should
be able to use the previous sourcerer component with no issues.

Optional (this is WIP):

On some pages, changing the view using that picker should result in
changes to data loaded (inspect the queries made to see if the correct
index is picked).

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
christineweng added a commit that referenced this pull request Jun 10, 2025
… Data View Picker (#210585) (#223044)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Security Solution][Sourcerer] Replace Sourcerer with Discover Data
View Picker (#210585)](#210585)
- [[Security Solution] Rename use_data_view to use_data_view_spec
#216461](#216461)
- [[Security Solution] Rename use full data view hook
#216614](#216614)
- [[Security Solution] Replace sourcerer in global header
#216685](#216685)
- [[Security Solution] Remove .title use in use_selected_patterns
#216994](#216994)
- [[Security Solution] Render default security solution data view with
managed label #216961](#216961)
- [[Security Solution] Replace sourcerer in analyzer
#218183](#218183)
- [[Security Solution] Replace use_sourcerer_data_view
#216997](#216997)
- [[Security Solution] Replace sourcerer in EQL tab with dataview picker
#218897](#218897)
- [[Security Solution][Sourcerer] replace use get scoped data view
#220196](#220196)
- [[Security Solution] renaming dataView to dataViewSpec and adding
types for clarity
#220718](#220718)
- [[Security Solution][Sourcerer] Maintain url sync support
#221737](#221737)
- [[Security Solution][Data View Manager] Allow passing data view to
query bar #220585](#220585)
- [[Security Solution] Fix data view picker privilege
#222122](#222122)



<!--- Backport version: 10.0.0 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Luke
Gmys","email":"11671118+lgestc@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-03-31T12:12:57Z","message":"[Security
Solution][Sourcerer] Replace Sourcerer with Discover Data View Picker
(#210585)\n\n# Unified Data View Picker: Phase 1 Implementation\nPart of
https://github.com/elastic/security-team/issues/11959\n\n## What This PR
Does\nThis PR represents the first step in our transition from the
current\nSourcerer component to the new unified Data View Picker.
Specifically,\nthis implementation:\n- Creates a new Data View Picker
component\n- Implements feature flag protection for all changes\n-
Handles asynchronous effects through Redux listener middleware\n-
Establishes a new Redux store architecture to support ad hoc data\nviews
infrastructure\n- Utilizes ad hoc data views to handle legacy patterns
from series 7\n(replacing the previous upgrade data view flow)\n\nSee
the readme for more info:
\n```x-pack/solutions/security/plugins/security_solution/public/data_view_manager/readme.md```\n\n##
What This PR Does NOT Cover\n- Does not affect screens other than
Timelines\n- Does not modify the existing Sourcerer component in any
way\n- Does not fully support all URL/local storage patterns\n\n##
Implementation Notes\nWe've made several accommodations to support both
Sourcerer and the new Data View Picker simultaneously during this
transition period, including:\n- Some interfaces might look odd,
especially the hooks that return the data view or patterns - this is
intentional to support existing use cases\n- There are feature
flag-based conditional statements throughout the code that will be
removed once the transition is complete\n\n## Testing Instructions\n1.
Add the following feature flag to your configuration:\n ```\n
xpack.securitySolution.enableExperimental:
['newDataViewPickerEnabled']\n ```\n2. Navigate to the Timelines
interface\n3. Test interactions with the new Data View
Picker\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"9679f2941550856d75e00c1faadd8c9669afe917","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","backport:skip","Team:
SecuritySolution","Team:Threat
Hunting:Investigations","Feature:Sourcerer","9.1
candidate","v9.1.0"],"title":"[Security Solution][Sourcerer] Replace
Sourcerer with Discover Data View
Picker","number":210585,"url":"https://github.com/elastic/kibana/pull/210585","mergeCommit":{"message":"[Security
Solution][Sourcerer] Replace Sourcerer with Discover Data View Picker
(#210585)\n\n# Unified Data View Picker: Phase 1 Implementation\nPart of
https://github.com/elastic/security-team/issues/11959\n\n## What This PR
Does\nThis PR represents the first step in our transition from the
current\nSourcerer component to the new unified Data View Picker.
Specifically,\nthis implementation:\n- Creates a new Data View Picker
component\n- Implements feature flag protection for all changes\n-
Handles asynchronous effects through Redux listener middleware\n-
Establishes a new Redux store architecture to support ad hoc data\nviews
infrastructure\n- Utilizes ad hoc data views to handle legacy patterns
from series 7\n(replacing the previous upgrade data view flow)\n\nSee
the readme for more info:
\n```x-pack/solutions/security/plugins/security_solution/public/data_view_manager/readme.md```\n\n##
What This PR Does NOT Cover\n- Does not affect screens other than
Timelines\n- Does not modify the existing Sourcerer component in any
way\n- Does not fully support all URL/local storage patterns\n\n##
Implementation Notes\nWe've made several accommodations to support both
Sourcerer and the new Data View Picker simultaneously during this
transition period, including:\n- Some interfaces might look odd,
especially the hooks that return the data view or patterns - this is
intentional to support existing use cases\n- There are feature
flag-based conditional statements throughout the code that will be
removed once the transition is complete\n\n## Testing Instructions\n1.
Add the following feature flag to your configuration:\n ```\n
xpack.securitySolution.enableExperimental:
['newDataViewPickerEnabled']\n ```\n2. Navigate to the Timelines
interface\n3. Test interactions with the new Data View
Picker\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"9679f2941550856d75e00c1faadd8c9669afe917"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/210585","number":210585,"mergeCommit":{"message":"[Security
Solution][Sourcerer] Replace Sourcerer with Discover Data View Picker
(#210585)\n\n# Unified Data View Picker: Phase 1 Implementation\nPart of
https://github.com/elastic/security-team/issues/11959\n\n## What This PR
Does\nThis PR represents the first step in our transition from the
current\nSourcerer component to the new unified Data View Picker.
Specifically,\nthis implementation:\n- Creates a new Data View Picker
component\n- Implements feature flag protection for all changes\n-
Handles asynchronous effects through Redux listener middleware\n-
Establishes a new Redux store architecture to support ad hoc data\nviews
infrastructure\n- Utilizes ad hoc data views to handle legacy patterns
from series 7\n(replacing the previous upgrade data view flow)\n\nSee
the readme for more info:
\n```x-pack/solutions/security/plugins/security_solution/public/data_view_manager/readme.md```\n\n##
What This PR Does NOT Cover\n- Does not affect screens other than
Timelines\n- Does not modify the existing Sourcerer component in any
way\n- Does not fully support all URL/local storage patterns\n\n##
Implementation Notes\nWe've made several accommodations to support both
Sourcerer and the new Data View Picker simultaneously during this
transition period, including:\n- Some interfaces might look odd,
especially the hooks that return the data view or patterns - this is
intentional to support existing use cases\n- There are feature
flag-based conditional statements throughout the code that will be
removed once the transition is complete\n\n## Testing Instructions\n1.
Add the following feature flag to your configuration:\n ```\n
xpack.securitySolution.enableExperimental:
['newDataViewPickerEnabled']\n ```\n2. Navigate to the Timelines
interface\n3. Test interactions with the new Data View
Picker\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"9679f2941550856d75e00c1faadd8c9669afe917"}}]}]
BACKPORT-->

---------

Co-authored-by: Luke Gmys <11671118+lgestc@users.noreply.github.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Philippe Oberti <philippe.oberti@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

9.1 candidate backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting:Investigations Security Solution Threat Hunting Investigations Team v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants