Skip to content

[Security Solution][Sourcerer] Default data view init flow for the DV manager#221338

Merged
lgestc merged 36 commits intoelastic:mainfrom
lgestc:default_data_view_init
Jun 19, 2025
Merged

[Security Solution][Sourcerer] Default data view init flow for the DV manager#221338
lgestc merged 36 commits intoelastic:mainfrom
lgestc:default_data_view_init

Conversation

@lgestc
Copy link
Copy Markdown
Contributor

@lgestc lgestc commented May 23, 2025

Summary

This PR reuses sourcerer data view creation logic for security solution and applies it to the new flow with data view manager (discover data view picker).

Closes https://github.com/elastic/security-team/issues/12570
Closes #220589

Testing

Starting kibana from scratch with the feature flag enabled should create default security solution view, in either default or custom Kibana Space.

The FF:

xpack.securitySolution.enableExperimental: ['newDataViewPickerEnabled']

Checklist

Check the PR satisfies following conditions.

@lgestc lgestc added 9.1 candidate Feature:Sourcerer backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes v9.1.0 Team:Threat Hunting:Investigations Security Solution Threat Hunting Investigations Team labels May 26, 2025
@elastic elastic deleted a comment from elasticmachine May 27, 2025
@lgestc lgestc marked this pull request as ready for review May 27, 2025 08:36
@lgestc lgestc requested review from a team as code owners May 27, 2025 08:36
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/security-threat-hunting-investigations (Team:Threat Hunting:Investigations)

}

// check for/generate default Security Solution Kibana data view
const sourcererDataViews = await createSourcererDataView({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is my understanding correct?

  • we want to retain the createSourererDataView method to get the default data views (plus renaming sourcerer reference in clean up)
  • we don't need the kibana data views since they are replaced in the shared redux slice
  • don't need signal either

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not sure about signal

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We do need signal for now, but won't ideally once the actual Security Solution Alerts dataView is created that only looks at that, then we shouldn't have to append it here and the detections scope can just be set to that one. But the same space specific logic will need to be applied to that one

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, while not super impactful from a performance perspective, createSourcererDataView has a number of unnecessary loops over a pattern list and seemingly duplicated behavior around setting the dataview title property. Doesn't need to be part of this PR, but we can include cleaning that up as part of the cleanup for this work

@michaelolo24
Copy link
Copy Markdown
Contributor

michaelolo24 commented Jun 3, 2025

It looks like the dataview loading error is still happening in the newly created spaces

Ignore this, my UI was just in a weird state.

One thing, can you update the references to this hardcoded pattern here for the default space security-solution-default:

export const DEFAULT_SECURITY_SOLUTION_DATA_VIEW_ID = 'security-solution-default';
? You can probably just either reference the id from the store (preferred) or create a hook that utilized useSpaceId

@lgestc lgestc requested a review from christineweng June 18, 2025 13:28
@lgestc lgestc added backport:prev-major and removed backport:skip This PR does not require backporting labels Jun 18, 2025
/* eslint-disable react-hooks/rules-of-hooks */
// NOTE: skipping the entire hook on purpose when the new picker is enabled
// will be removed as part of the cleanup in https://github.com/elastic/security-team/issues/11959
if (newDataViewPickerEnabled) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this will prevent the sourcerer init actions entirely if the new picker is enabled

Copy link
Copy Markdown
Contributor Author

@lgestc lgestc left a comment

Choose a reason for hiding this comment

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

added a few comments for the reviewers

@lgestc lgestc added backport:version Backport to applied version labels v8.19.0 and removed backport:prev-major labels Jun 18, 2025
@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #114 / alerting api integration security and spaces enabled - Group 2 Connectors ServiceNow ITSM ServiceNow ITSM - Executor Execution closeIncident should close the incident

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 7635 7637 +2

Async chunks

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

id before after diff
securitySolution 9.4MB 9.4MB +2.0KB

Page load bundle

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

id before after diff
securitySolution 94.8KB 94.8KB +6.0B
Unknown metric groups

ESLint disabled in files

id before after diff
securitySolution 94 95 +1

ESLint disabled line counts

id before after diff
securitySolution 620 621 +1

Total ESLint disabled count

id before after diff
securitySolution 714 716 +2

History

Copy link
Copy Markdown
Contributor

@christineweng christineweng left a comment

Choose a reason for hiding this comment

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

LGTM, great work @lgestc 👏

import type { DataViewManagerScopeName } from '../../constants';

/**
* Creates a Redux listener for handling data view selection logic in the data view manager.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👏🏾

// NOTE: save default data id for the given space in the store.
// this is used to identify the default selection in pickers across Kibana Space
listenerApi.dispatch(
sharedDataViewManagerSlice.actions.setDefaultDataViewId(defaultDataView.id)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍🏾


export interface SignalIndexMetadata {
name: string;
isOutdated: boolean;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add a comment for this?

});
const experimentalSignalIndexMappingOutdated = useSelector(signalIndexOutdatedSelector);

const signalIndexMappingOutdated = newDataViewPickerEnabled
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍🏾 , I would just point to this for the isOutdated line in the store

Copy link
Copy Markdown
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! Thanks for fixing the spaces dataView creation. Works well now 👍🏾

lgestc and others added 2 commits June 19, 2025 09:32
…a_view_manager/redux/listeners/init_listener.ts

Co-authored-by: Michael Olorunnisola <michael.olorunnisola@elastic.co>
@lgestc lgestc enabled auto-merge (squash) June 19, 2025 07:33
@lgestc lgestc merged commit e6ed157 into elastic:main Jun 19, 2025
10 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.19

https://github.com/elastic/kibana/actions/runs/15754430337

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jun 19, 2025
… manager (elastic#221338)

## Summary

This PR reuses sourcerer data view creation logic for security solution
and applies it to the new flow with data view manager (discover data
view picker).

Closes elastic/security-team#12570
Closes elastic#220589

## Testing

Starting kibana from scratch with the feature flag enabled should create
default security solution view, **in either default or custom Kibana
Space**.

The FF:

```
xpack.securitySolution.enableExperimental: ['newDataViewPickerEnabled']
```

### Checklist

Check the PR satisfies following conditions.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated / added

---------

Co-authored-by: Michael Olorunnisola <michael.olorunnisola@elastic.co>
(cherry picked from commit e6ed157)
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jun 19, 2025
… the DV manager (#221338) (#224534)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Security Solution][Sourcerer] Default data view init flow for the DV
manager (#221338)](#221338)

<!--- Backport version: 9.6.6 -->

### 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-06-19T09:25:24Z","message":"[Security
Solution][Sourcerer] Default data view init flow for the DV manager
(#221338)\n\n## Summary\n\nThis PR reuses sourcerer data view creation
logic for security solution\nand applies it to the new flow with data
view manager (discover data\nview picker).\n\nCloses
https://github.com/elastic/security-team/issues/12570\nCloses
https://github.com/elastic/kibana/issues/220589\n\n##
Testing\n\nStarting kibana from scratch with the feature flag enabled
should create\ndefault security solution view, **in either default or
custom Kibana\nSpace**.\n\nThe
FF:\n\n```\nxpack.securitySolution.enableExperimental:
['newDataViewPickerEnabled']\n```\n\n### Checklist\n\nCheck the PR
satisfies following conditions. \n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated / added\n\n---------\n\nCo-authored-by: Michael Olorunnisola
<michael.olorunnisola@elastic.co>","sha":"e6ed157f2019d2298b80f70404a87ac29f418ae2","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Threat
Hunting:Investigations","Feature:Sourcerer","backport:version","9.1
candidate","v9.1.0","v8.19.0"],"title":"[Security Solution][Sourcerer]
Default data view init flow for the DV
manager","number":221338,"url":"https://github.com/elastic/kibana/pull/221338","mergeCommit":{"message":"[Security
Solution][Sourcerer] Default data view init flow for the DV manager
(#221338)\n\n## Summary\n\nThis PR reuses sourcerer data view creation
logic for security solution\nand applies it to the new flow with data
view manager (discover data\nview picker).\n\nCloses
https://github.com/elastic/security-team/issues/12570\nCloses
https://github.com/elastic/kibana/issues/220589\n\n##
Testing\n\nStarting kibana from scratch with the feature flag enabled
should create\ndefault security solution view, **in either default or
custom Kibana\nSpace**.\n\nThe
FF:\n\n```\nxpack.securitySolution.enableExperimental:
['newDataViewPickerEnabled']\n```\n\n### Checklist\n\nCheck the PR
satisfies following conditions. \n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated / added\n\n---------\n\nCo-authored-by: Michael Olorunnisola
<michael.olorunnisola@elastic.co>","sha":"e6ed157f2019d2298b80f70404a87ac29f418ae2"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/221338","number":221338,"mergeCommit":{"message":"[Security
Solution][Sourcerer] Default data view init flow for the DV manager
(#221338)\n\n## Summary\n\nThis PR reuses sourcerer data view creation
logic for security solution\nand applies it to the new flow with data
view manager (discover data\nview picker).\n\nCloses
https://github.com/elastic/security-team/issues/12570\nCloses
https://github.com/elastic/kibana/issues/220589\n\n##
Testing\n\nStarting kibana from scratch with the feature flag enabled
should create\ndefault security solution view, **in either default or
custom Kibana\nSpace**.\n\nThe
FF:\n\n```\nxpack.securitySolution.enableExperimental:
['newDataViewPickerEnabled']\n```\n\n### Checklist\n\nCheck the PR
satisfies following conditions. \n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated / added\n\n---------\n\nCo-authored-by: Michael Olorunnisola
<michael.olorunnisola@elastic.co>","sha":"e6ed157f2019d2298b80f70404a87ac29f418ae2"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Luke Gmys <11671118+lgestc@users.noreply.github.com>
Co-authored-by: Michael Olorunnisola <michael.olorunnisola@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:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting:Investigations Security Solution Threat Hunting Investigations Team v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security Solution][Data View Manager] Support non-default space

5 participants