-
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
[Security Solution] Discover Timeline Integration URL Sync + Fixes #163305
[Security Solution] Discover Timeline Integration URL Sync + Fixes #163305
Conversation
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.
Code-only review so far. The Discover changes are looking good to me overall! Just have a few initial questions and comments.
As an alternative, I wanted to use
customization fwk
for this but we are in catch-22 situation where we needstateContainer
to define a customization but we want to do customization while defining thestateContainer
. Let me know if you any ideas/thoughts regarding this.
Yeah I can see how this would be a challenge, and it would be difficult to change due to how Discover's state is all derived from the URL. I think this is a valid use of mode
though, so I'm fine with this approach. If we find ourselves needing mode
much more though, we may want to consider a simple abstraction using something like context over prop drilling.
src/plugins/discover/public/customizations/customization_types/histogram_customization.tsx
Outdated
Show resolved
Hide resolved
src/plugins/discover/public/customizations/customization_service.ts
Outdated
Show resolved
Hide resolved
src/plugins/discover/public/application/main/services/discover_state.test.ts
Outdated
Show resolved
Hide resolved
.../security_solution_cypress/cypress/e2e/investigations/timelines/discover/search_filter.cy.ts
Show resolved
Hide resolved
Just one more minor note. I'm not sure how we want to handle this, but currently creating a new timeline doesn't reset the discover state. We can probably handle that easily in a follow up pr |
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.
Really nice work here. Very well tested and very thought out. Really liked your code organization 👏🏾 👏🏾 . Refreshing, navigating to and from the discover tab, and closing and reopening timeline all retain the discover state (query, filters, histogram, table columns, rows per page, and unified field list). Had a few minor nits, and the clearing discover state on a new timeline...If we decide we want to do that. Really nice work @logeekal 🚀 LGTM!
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.
Apologies for the delay on this review, I got the chance today to doing another round of code review and some local testing. It seems to being working great! Everything I tested worked as expected including browser history, persisting Discover state when Timeline is minimized, and the custom histogram actions 👍
On a side note, the custom histogram actions are a great use of the customization framework. One idea I'd suggest as a future improvement (but out of scope of this PR) would be to leverage the customization framework to use the same cell actions in Timeline Discover that are used in Security Dashboards saved search panels, now that the Discover grid supports cell actions.
This is just about ready to go on my end. I left a couple of very minor suggestions, but mainly just a concern about some of the state syncing logic in the Discover tab.
packages/kbn-unified-field-list/src/components/field_list/field_list.tsx
Outdated
Show resolved
Hide resolved
* mode in which discover is running | ||
* | ||
* */ | ||
mode?: DiscoverDisplayMode; |
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 don't think I understand this suggestion. Are you referring to redirecting requests to Discover to another app based on an appId
prop?
...lugins/security_solution/public/timelines/components/timeline/discover_tab_content/index.tsx
Outdated
Show resolved
Hide resolved
Yep, follow up PR will have this functionality. I think it makes sense to have this functionality in conjunction with saving. |
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.
Thanks for the latest changes! Pulled and tested locally again and everything is still working as expected + no more duplicate state subscriptions. Great work on this, LGTM 👍
...lugins/security_solution/public/timelines/components/timeline/discover_tab_content/index.tsx
Outdated
Show resolved
Hide resolved
* mode in which discover is running | ||
* | ||
* */ | ||
mode?: DiscoverDisplayMode; |
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.
yes, for determining path, if discover is being used at a different path in both security and observability serverless modes.
Observability currently doesn't use Discover at a different path or embedded in another app. They're using the profile
functionality in the customization framework to customize Discover as a top level app, so their use case around URLs and paths is a bit different (and already supported).
guess that might not work with locators and the like, as those run during discover setup.
Yeah I agree, I don't think this would be possible through the container component.
Probably makes more sense to do something at a config level then? maybe a discover.location setting that we set only in serverless.obit.yml/serverless.security.yml?
I'd like for the Security redirecting logic not to live in the Discover codebase or be owned/maintained by the Data Discovery team, so I'd prefer not to take this approach. I'd be open to a YAML config that disables access to Discover as a top level app or similar, but owning and maintaining the redirect logic should be the responsibility of the Security Solution.
Does it make sense to add parameter in discover.locator called, appId where locator will develop the URL based on the appID given?
I'd also prefer to avoid this since it would introduce knowledge of the Security redirect logic directly into the Discover codebase.
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 had a review and no issue so far from testing locally.
I would like also @stratoula opinion here before approving tho.
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.
@logeekal thanx for trying my suggestion, it is fine. LGTM!
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
History
To update your PR or re-run it, just comment with: |
…lastic#163305) This PR looks at adding below functionalities to Discover Timeline Integration: ## Discover state URL Sync. It changes the url sync strategy ( based on whether the discover is running in `standalone` or `embedded` mode ) of discover so that is easy for security solution to read/change the global/local state in the url. |Before|After| |--|--| |`http://localhost:5601/app/discover?#/?_g=(filters:!(),refreshInterval:(pause:!t,value:60000),time:(from:now-15m,to:now))&_a=(columns:!(),filters:!(),index:security-solution-default,interval:auto,query:(language:kuery,query:''),sort:!(!('@timestamp',desc)))`|`http://localhost:5601/app/security/alerts?_g=(filters:!(),refreshInterval:(pause:!t,value:60000),time:(from:now-15m,to:now))&_a=(columns:!(),filters:!(),index:security-solution-default,interval:auto,query:(language:kuery,query:%27%27),sort:!(!(%27@timestamp%27,desc)))`| @davismcphee As an alternative, I wanted to use `customization fwk` for this but we are in catch-22 situation where we need `stateContainer` to define a customization but we want to do customization while defining the `stateContainer`. Let me know if you any ideas/thoughts regarding this. ## Lens visualizations UI actions customization Lens visualization has triggers for certain ui actions. Below are those triggers: 1. Brush 2. Single Value Filter 3. Multiple Value Filter 4.⚠️ `tableRowContextMenuClick` - Not sure what is this. https://github.com/elastic/kibana/blob/48b7acfd2427d9927d4a62ca658592c4b7a5bbb2/src/plugins/visualizations/public/embeddable/events.ts#L24-L31 This triggers are bound to the global data services, which causes issue when triggered in security solution. Lens provided a way to override these `triggers` via component props. This PR use customization fwk to override and pass those props. Below videos shows the demo. https://github.com/elastic/kibana/assets/7485038/29034f5b-f0f3-4753-a291-f88ecaabb8e6 ## Discover state persistant in Security Solution - This PR adds discover's app state it in Security solution Redux. - [x] TODO - Syncing with local storage remaining. Will commit soon in this PR. ## Unit / Cypress Tests - Added unit tests + cypress tests - [x] TODO - Some are still in progress. -⚠️ TODO - Copy these cypress tests to serverless environment. --------- Co-authored-by: kibanamachine <[email protected]> (cherry picked from commit edef2e2)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
This PR looks at adding below functionalities to Discover Timeline Integration:
Discover state URL Sync.
It changes the url sync strategy ( based on whether the discover is running in
standalone
orembedded
mode ) of discover so that is easy for security solution to read/change the global/local state in the url.http://localhost:5601/app/discover?#/?_g=(filters:!(),refreshInterval:(pause:!t,value:60000),time:(from:now-15m,to:now))&_a=(columns:!(),filters:!(),index:security-solution-default,interval:auto,query:(language:kuery,query:''),sort:!(!('@timestamp',desc)))
http://localhost:5601/app/security/alerts?_g=(filters:!(),refreshInterval:(pause:!t,value:60000),time:(from:now-15m,to:now))&_a=(columns:!(),filters:!(),index:security-solution-default,interval:auto,query:(language:kuery,query:%27%27),sort:!(!(%27@timestamp%27,desc)))
@davismcphee
As an alternative, I wanted to use
customization fwk
for this but we are in catch-22 situation where we needstateContainer
to define a customization but we want to do customization while defining thestateContainer
. Let me know if you any ideas/thoughts regarding this.Lens visualizations UI actions customization
Lens visualization has triggers for certain ui actions. Below are those triggers:
tableRowContextMenuClick
- Not sure what is this.kibana/src/plugins/visualizations/public/embeddable/events.ts
Lines 24 to 31 in 48b7acf
This triggers are bound to the global data services, which causes issue when triggered in security solution. Lens provided a way to override these
triggers
via component props. This PR use customization fwk to override and pass those props. Below videos shows the demo.Screen.Recording.2023-08-10.at.15.36.50.mov
Discover state persistant in Security Solution
Unit / Cypress Tests