Skip to content
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

[Siem migrations] Implement UI service and migrations polling #201503

Merged
merged 6 commits into from
Nov 25, 2024

Conversation

semd
Copy link
Contributor

@semd semd commented Nov 23, 2024

Summary

Sends "Rule migration complete" notifications from anywhere in the Security Solution app, whenever a rule migration finishes, with a link to the migrated rules.

The polling logic has been encapsulated in the new siemMigrations.rules service so the request loop is centralized in one place. The value updates are broadcasted using the latestStats$ observable.
It will only keep requesting while there are running migrations and will stop automatically when no more migrations are running.

The reusable useLatestStats hook has been created for the UI components to consume. This approach allows multiple components to listen and update their content automatically with every rule migration stats update, having only one request loop running.

The polling will only start if it's not already running and only if the SIEM migration functionality is available, which includes:

  • Experimental flag enabled
  • Enterprise license
  • TODO: feature capability check (RBAC issue)

The polling will try to start when:

  • Automatically with the Security Solution application starts
  • The first render of every page that uses useLatestStats hook.
  • TODO: A new migration is created from the onboarding page (issue)

Tests will be implemented in this task

Example

A Rule migration finishes while using Timeline in the Alerts page:

rule_migrations_notifications.mov

@semd semd added release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting Security Solution Threat Hunting Team backport:version Backport to applied version labels v8.18.0 labels Nov 23, 2024
@semd semd self-assigned this Nov 23, 2024
@semd semd requested review from a team as code owners November 23, 2024 15:38
@elasticmachine
Copy link
Contributor

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

@semd semd changed the title [Siem migrations] Implement UI polling with [Siem migrations] Implement UI service and stats polling Nov 25, 2024
@semd semd changed the title [Siem migrations] Implement UI service and stats polling [Siem migrations] Implement UI service and migrations polling Nov 25, 2024
Copy link
Contributor

@e40pud e40pud left a comment

Choose a reason for hiding this comment

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

Looks great!! We will need to add route handler to be able to open a specific migration.


const SuccessToastContent: React.FC<{ migration: RuleMigrationStats }> = ({ migration }) => {
const { migration_id: path, rules } = migration;
const navigation = { deepLinkId: SecurityPageName.siemMigrationsRules, path };
Copy link
Contributor

Choose a reason for hiding this comment

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

We will need to add a route to handle migration_id as a path parameter (somewhere here x-pack/plugins/security_solution/public/siem_migrations/routes.tsx). Right now we only open a default page where we would pick the first available migration and use it.

@bojanasan
Copy link

bojanasan commented Nov 25, 2024

@semd looks great! I'll work with @benironside on copy. When possible it would be great to update the styling.

image

mock link

@@ -226,30 +229,34 @@ export class RuleMigrationsDataRulesClient extends RuleMigrationsDataBaseClient
throw error;
});

const { pending, processing, completed, lastUpdatedAt, failed } = result.aggregations ?? {};
// const { pending, processing, completed, lastUpdatedAt, createdAt, failed }
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this line anymore, right?

@elasticmachine
Copy link
Contributor

elasticmachine commented Nov 25, 2024

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 6259 6263 +4

Async chunks

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

id before after diff
securitySolution 13.3MB 13.4MB +6.6KB

Page load bundle

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

id before after diff
securitySolution 86.4KB 86.6KB +152.0B
Unknown metric groups

async chunk count

id before after diff
securitySolution 100 101 +1

ESLint disabled line counts

id before after diff
securitySolution 555 556 +1

Total ESLint disabled count

id before after diff
securitySolution 640 641 +1

History

cc @semd

@semd semd merged commit b6586a9 into elastic:main Nov 25, 2024
46 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

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

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 25, 2024
…c#201503)

## Summary

Sends "Rule migration complete" notifications from anywhere in the
Security Solution app, whenever a rule migration finishes, with a link
to the migrated rules.

The polling logic has been encapsulated in the new
`siemMigrations.rules` service so the request loop is centralized in one
place. The value updates are broadcasted using the `latestStats$`
observable.
It will only keep requesting while there are _running_ migrations and
will stop automatically when no more migrations are _running_.

The reusable `useLatestStats` hook has been created for the UI
components to consume. This approach allows multiple components to
listen and update their content automatically with every rule migration
stats update, having only one request loop running.

The polling will only start if it's not already running and only if the
SIEM migration functionality is available, which includes:
- Experimental flag enabled
- _Enterprise_ license
- TODO: feature capability check (RBAC
[issue](elastic/security-team#11262))

The polling will try to start when:
- Automatically with the Security Solution application starts
- The first render of every page that uses `useLatestStats` hook.
- TODO: A new migration is created from the onboarding page
([issue](elastic/security-team#10667))

Tests will be implemented in [this
task](elastic/security-team#11256)

## Example

A Rule migration finishes while using Timeline in the Alerts page:

https://github.com/user-attachments/assets/aac2b2c8-27fe-40d5-9f32-0bee74c9dc6a
(cherry picked from commit b6586a9)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

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 Nov 25, 2024
…201503) (#201664)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Siem migrations] Implement UI service and migrations polling
(#201503)](#201503)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Sergi
Massaneda","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-25T17:48:02Z","message":"[Siem
migrations] Implement UI service and migrations polling (#201503)\n\n##
Summary\r\n\r\nSends \"Rule migration complete\" notifications from
anywhere in the\r\nSecurity Solution app, whenever a rule migration
finishes, with a link\r\nto the migrated rules.\r\n\r\nThe polling logic
has been encapsulated in the new\r\n`siemMigrations.rules` service so
the request loop is centralized in one\r\nplace. The value updates are
broadcasted using the `latestStats# Backport

This will backport the following commits from `main` to `8.x`:
- [[Siem migrations] Implement UI service and migrations polling
(#201503)](#201503)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT \r\nobservable.\r\nIt will only keep requesting while there
are _running_ migrations and\r\nwill stop automatically when no more
migrations are _running_.\r\n\r\nThe reusable `useLatestStats` hook has
been created for the UI\r\ncomponents to consume. This approach allows
multiple components to\r\nlisten and update their content automatically
with every rule migration\r\nstats update, having only one request loop
running.\r\n\r\nThe polling will only start if it's not already running
and only if the\r\nSIEM migration functionality is available, which
includes:\r\n- Experimental flag enabled\r\n- _Enterprise_ license \r\n-
TODO: feature capability check
(RBAC\r\n[issue](https://github.com/elastic/security-team/issues/11262))\r\n\r\nThe
polling will try to start when:\r\n- Automatically with the Security
Solution application starts\r\n- The first render of every page that
uses `useLatestStats` hook.\r\n- TODO: A new migration is created from
the onboarding
page\r\n([issue](https://github.com/elastic/security-team/issues/10667))\r\n\r\nTests
will be implemented in
[this\r\ntask](https://github.com/elastic/security-team/issues/11256)\r\n\r\n##
Example\r\n\r\nA Rule migration finishes while using Timeline in the
Alerts
page:\r\n\r\n\r\nhttps://github.com/user-attachments/assets/aac2b2c8-27fe-40d5-9f32-0bee74c9dc6a","sha":"b6586a95f2f5fb0bd79a5d79bfd6ae85d91adbe4","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Threat
Hunting","backport:version","v8.18.0"],"title":"[Siem migrations]
Implement UI service and migrations
polling","number":201503,"url":"https://github.com/elastic/kibana/pull/201503","mergeCommit":{"message":"[Siem
migrations] Implement UI service and migrations polling (#201503)\n\n##
Summary\r\n\r\nSends \"Rule migration complete\" notifications from
anywhere in the\r\nSecurity Solution app, whenever a rule migration
finishes, with a link\r\nto the migrated rules.\r\n\r\nThe polling logic
has been encapsulated in the new\r\n`siemMigrations.rules` service so
the request loop is centralized in one\r\nplace. The value updates are
broadcasted using the `latestStats# Backport

This will backport the following commits from `main` to `8.x`:
- [[Siem migrations] Implement UI service and migrations polling
(#201503)](#201503)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT \r\nobservable.\r\nIt will only keep requesting while there
are _running_ migrations and\r\nwill stop automatically when no more
migrations are _running_.\r\n\r\nThe reusable `useLatestStats` hook has
been created for the UI\r\ncomponents to consume. This approach allows
multiple components to\r\nlisten and update their content automatically
with every rule migration\r\nstats update, having only one request loop
running.\r\n\r\nThe polling will only start if it's not already running
and only if the\r\nSIEM migration functionality is available, which
includes:\r\n- Experimental flag enabled\r\n- _Enterprise_ license \r\n-
TODO: feature capability check
(RBAC\r\n[issue](https://github.com/elastic/security-team/issues/11262))\r\n\r\nThe
polling will try to start when:\r\n- Automatically with the Security
Solution application starts\r\n- The first render of every page that
uses `useLatestStats` hook.\r\n- TODO: A new migration is created from
the onboarding
page\r\n([issue](https://github.com/elastic/security-team/issues/10667))\r\n\r\nTests
will be implemented in
[this\r\ntask](https://github.com/elastic/security-team/issues/11256)\r\n\r\n##
Example\r\n\r\nA Rule migration finishes while using Timeline in the
Alerts
page:\r\n\r\n\r\nhttps://github.com/user-attachments/assets/aac2b2c8-27fe-40d5-9f32-0bee74c9dc6a","sha":"b6586a95f2f5fb0bd79a5d79bfd6ae85d91adbe4"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201503","number":201503,"mergeCommit":{"message":"[Siem
migrations] Implement UI service and migrations polling (#201503)\n\n##
Summary\r\n\r\nSends \"Rule migration complete\" notifications from
anywhere in the\r\nSecurity Solution app, whenever a rule migration
finishes, with a link\r\nto the migrated rules.\r\n\r\nThe polling logic
has been encapsulated in the new\r\n`siemMigrations.rules` service so
the request loop is centralized in one\r\nplace. The value updates are
broadcasted using the `latestStats# Backport

This will backport the following commits from `main` to `8.x`:
- [[Siem migrations] Implement UI service and migrations polling
(#201503)](#201503)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT \r\nobservable.\r\nIt will only keep requesting while there
are _running_ migrations and\r\nwill stop automatically when no more
migrations are _running_.\r\n\r\nThe reusable `useLatestStats` hook has
been created for the UI\r\ncomponents to consume. This approach allows
multiple components to\r\nlisten and update their content automatically
with every rule migration\r\nstats update, having only one request loop
running.\r\n\r\nThe polling will only start if it's not already running
and only if the\r\nSIEM migration functionality is available, which
includes:\r\n- Experimental flag enabled\r\n- _Enterprise_ license \r\n-
TODO: feature capability check
(RBAC\r\n[issue](https://github.com/elastic/security-team/issues/11262))\r\n\r\nThe
polling will try to start when:\r\n- Automatically with the Security
Solution application starts\r\n- The first render of every page that
uses `useLatestStats` hook.\r\n- TODO: A new migration is created from
the onboarding
page\r\n([issue](https://github.com/elastic/security-team/issues/10667))\r\n\r\nTests
will be implemented in
[this\r\ntask](https://github.com/elastic/security-team/issues/11256)\r\n\r\n##
Example\r\n\r\nA Rule migration finishes while using Timeline in the
Alerts
page:\r\n\r\n\r\nhttps://github.com/user-attachments/assets/aac2b2c8-27fe-40d5-9f32-0bee74c9dc6a","sha":"b6586a95f2f5fb0bd79a5d79bfd6ae85d91adbe4"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Sergi Massaneda <[email protected]>
paulinashakirova pushed a commit to paulinashakirova/kibana that referenced this pull request Nov 26, 2024
…c#201503)

## Summary

Sends "Rule migration complete" notifications from anywhere in the
Security Solution app, whenever a rule migration finishes, with a link
to the migrated rules.

The polling logic has been encapsulated in the new
`siemMigrations.rules` service so the request loop is centralized in one
place. The value updates are broadcasted using the `latestStats$`
observable.
It will only keep requesting while there are _running_ migrations and
will stop automatically when no more migrations are _running_.

The reusable `useLatestStats` hook has been created for the UI
components to consume. This approach allows multiple components to
listen and update their content automatically with every rule migration
stats update, having only one request loop running.

The polling will only start if it's not already running and only if the
SIEM migration functionality is available, which includes:
- Experimental flag enabled
- _Enterprise_ license 
- TODO: feature capability check (RBAC
[issue](elastic/security-team#11262))

The polling will try to start when:
- Automatically with the Security Solution application starts
- The first render of every page that uses `useLatestStats` hook.
- TODO: A new migration is created from the onboarding page
([issue](elastic/security-team#10667))

Tests will be implemented in [this
task](elastic/security-team#11256)

## Example

A Rule migration finishes while using Timeline in the Alerts page:


https://github.com/user-attachments/assets/aac2b2c8-27fe-40d5-9f32-0bee74c9dc6a
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
…c#201503)

## Summary

Sends "Rule migration complete" notifications from anywhere in the
Security Solution app, whenever a rule migration finishes, with a link
to the migrated rules.

The polling logic has been encapsulated in the new
`siemMigrations.rules` service so the request loop is centralized in one
place. The value updates are broadcasted using the `latestStats$`
observable.
It will only keep requesting while there are _running_ migrations and
will stop automatically when no more migrations are _running_.

The reusable `useLatestStats` hook has been created for the UI
components to consume. This approach allows multiple components to
listen and update their content automatically with every rule migration
stats update, having only one request loop running.

The polling will only start if it's not already running and only if the
SIEM migration functionality is available, which includes:
- Experimental flag enabled
- _Enterprise_ license 
- TODO: feature capability check (RBAC
[issue](elastic/security-team#11262))

The polling will try to start when:
- Automatically with the Security Solution application starts
- The first render of every page that uses `useLatestStats` hook.
- TODO: A new migration is created from the onboarding page
([issue](elastic/security-team#10667))

Tests will be implemented in [this
task](elastic/security-team#11256)

## Example

A Rule migration finishes while using Timeline in the Alerts page:


https://github.com/user-attachments/assets/aac2b2c8-27fe-40d5-9f32-0bee74c9dc6a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting Security Solution Threat Hunting Team v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants