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

[ResponseOps][Alerts] Move the alerts table to a dedicated package #207878

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

umbopepato
Copy link
Member

@umbopepato umbopepato commented Jan 22, 2025

Summary

This PR turns the AlertsTable into a standalone component, making it independent from the TriggersActionsUI plugin.

Removes the alerts table registry

All configuration is now managed through the AlertsTable component props. Shared configurations are handled by giving consumers the ability to directly provide alerts table wrapper components (see for example the renderAlertsTable prop of getCases).

Moves the alerts table to dedicated package(s)

Following the feature-driven structure we're introducing for ResponseOps (alerting) client-side packages:

  • @kbn/response-ops-alerts-table
  • @kbn/response-ops-alerts-apis
  • @kbn/response-ops-alerts-fields-browser

Initial work on improving composition and organization

  • Reorganizes the table code into a by-entity-type folder structure (components/, hooks/, ...)
  • Simplifies some components and breaks into smaller units when possible

To verify

For consumers of the alerts table:

  • Check that all your tables have the same behavior as before (columns, sort, row actions, bulk actions, etc.)
  • Check that your "shared" tables (i.e. cases alerts view in O11y and Security) have the expected configuration and behavior

Warning

This PR moves a lot of files. Git might not always recognize the correct delete/add file pairs. If you see weird diffs feel free to reach out for help!

Checklist

Identify risks

Risk Description Severity Mitigation
Table misconfigurations Some table configurations might slightly differ from the previous AlertsTableRegistry-backed version Low Quick fix

References

Closes #195180

@umbopepato umbopepato force-pushed the alerts-table-refactor branch from 99c6d4d to 72b83e5 Compare January 22, 2025 17:44
@umbopepato umbopepato added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) labels Jan 23, 2025
@umbopepato umbopepato force-pushed the alerts-table-refactor branch from 72b83e5 to 002f502 Compare January 23, 2025 09:47
@umbopepato umbopepato marked this pull request as ready for review January 23, 2025 10:18
@umbopepato umbopepato requested review from a team as code owners January 23, 2025 10:18
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@umbopepato umbopepato requested review from a team as code owners January 23, 2025 10:18
@darnautov darnautov self-requested a review January 23, 2025 12:08
@jennypavlova jennypavlova self-requested a review January 23, 2025 14:01
Copy link
Member

@jennypavlova jennypavlova left a comment

Choose a reason for hiding this comment

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

ObsUx Infra and Services changes LGTM

@andrew-goldstein
Copy link
Contributor

Thanks @umbopepato for this PR!

Please consider merging main into this PR again.

At the time of this writing, this PR is waiting on approval from a few teams, so I merged #208293, which as @stephmilovic noted here and here, a couple of tests may fail when they are merged with the changes in this PR.

Thank you @stephmilovic for the heads-up!

@umbopepato umbopepato force-pushed the alerts-table-refactor branch from 5fa2235 to 5459a7d Compare January 27, 2025 22:27
@umbopepato
Copy link
Member Author

Thanks @umbopepato for this PR!

Please consider merging main into this PR again.

At the time of this writing, this PR is waiting on approval from a few teams, so I merged #208293, which as @stephmilovic noted here and here, a couple of tests may fail when they are merged with the changes in this PR.

Thank you @stephmilovic for the heads-up!

Rebased and updated the tests to the new standalone component! Thanks @andrew-goldstein 🙂

Copy link
Member

@machadoum machadoum left a comment

Choose a reason for hiding this comment

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

EA team changes LGTM!

Copy link
Contributor

@fkanout fkanout left a comment

Choose a reason for hiding this comment

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

Tested the PR locally and the Alert table worked as expected.

@umbopepato umbopepato added backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) v9.0.0 and removed backport:skip This commit does not require backporting labels Jan 28, 2025
Copy link
Contributor

@semd semd left a comment

Choose a reason for hiding this comment

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

Cell actions tested locally.
Threat hunting - Explore changes LGTM

umbopepato and others added 10 commits January 29, 2025 12:22
- Removes the alerts table registry in favor of a props-only
configuration
- Converts all the usages of the alerts table to use only props

- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [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: kibanamachine <[email protected]>
Co-authored-by: Christos Nasikas <[email protected]>
Moves the alerts table code and dependencies to dedicated packages in
`packages/response-ops/**`.

> [!IMPORTANT]
> 🚧 Merging to the `alerts-table-refactor` feature branch`

- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [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
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed

---------

Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Christos Nasikas <[email protected]>
…tCases (#207038)

## Summary

> [!IMPORTANT]
> 🚧 Merging to the `alerts-table-refactor` feature branch, no review
needed from teams other than `response-ops`

> [!WARNING]
> Some tests are intentionally left failing since the converted usages
of the alerts table still have to be validated/improved by solutions and
may change significantly

Adds a `renderAlertsTable` prop to `getCases` to allow solutions to
customize the alerts table shown in the `Alerts` tab of their case view.
## Summary

The Security Solution alerts table CellValue component was receiving
some wrong props when used in the Rule preview table. This PR removes
the spread `{...props}` expression and type cast that didn't catch this
error and correctly converts props and types.
…om security flyout (#208052)

## Summary

Fixes the toggleColumn functionality not working from the Security
Solution flyout. Uses a global context to share a reference to the
`toggleColumn` function as a **temporary solution** until the handling
of the columns inside the alerts table is refactored to correctly
receive updates from the outside.
@umbopepato umbopepato force-pushed the alerts-table-refactor branch from 4df554f to 1428348 Compare January 29, 2025 11:32
@elasticmachine
Copy link
Contributor

elasticmachine commented Jan 29, 2025

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #20 / Connector renders loading state correctly
  • [job] [logs] Jest Tests #20 / usePostCase invalidates the queries correctly

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
alerting 230 229 -1
cases 842 1032 +190
ml 2206 2430 +224
observability 1352 1447 +95
securitySolution 6624 6707 +83
slo 984 983 -1
threatIntelligence 139 177 +38
triggersActionsUi 944 927 -17
total +611

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/alerting-types 241 248 +7
@kbn/alerts-ui-shared 287 282 -5
@kbn/response-ops-alerts-fields-browser - 6 +6
@kbn/response-ops-alerts-table - 6 +6
observability 689 698 +9
ruleRegistry 222 221 -1
triggersActionsUi 570 543 -27
total -5

Async chunks

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

id before after diff
apm 4.0MB 4.0MB -452.0B
cases 540.5KB 1.3MB ⚠️ +805.2KB
cloudSecurityPosture 523.7KB 523.7KB +15.0B
discover 830.3KB 830.4KB +15.0B
infra 1.2MB 1.2MB -335.0B
ml 4.7MB 5.5MB ⚠️ +798.9KB
observability 1.3MB 1.4MB +88.7KB
securitySolution 21.4MB 18.8MB -2.6MB
slo 885.8KB 886.0KB +168.0B
synthetics 920.8KB 920.5KB -226.0B
threatIntelligence 57.6KB 758.0KB ⚠️ +700.3KB
triggersActionsUi 1.7MB 1.6MB -38.5KB
total -314.1KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/response-ops-alerts-apis - 1 +1
@kbn/response-ops-alerts-fields-browser - 2 +2
@kbn/response-ops-alerts-table - 13 +13
@kbn/securitysolution-data-table 6 10 +4
triggersActionsUi 51 40 -11
total +9

Page load bundle

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

id before after diff
cases 162.1KB 163.6KB +1.4KB
esqlDataGrid 9.4KB 9.4KB +15.0B
ml 78.0KB 79.4KB +1.4KB
observability 102.1KB 102.2KB +108.0B
securitySolution 88.3KB 87.8KB -511.0B
threatIntelligence 12.7KB 12.8KB +102.0B
triggersActionsUi 130.2KB 118.8KB -11.4KB
total -8.9KB
Unknown metric groups

API count

id before after diff
@kbn/alerting-types 244 252 +8
@kbn/alerts-ui-shared 303 298 -5
@kbn/response-ops-alerts-fields-browser - 15 +15
@kbn/response-ops-alerts-table - 8 +8
observability 697 706 +9
triggersActionsUi 596 561 -35
total -0

async chunk count

id before after diff
cases 32 34 +2
ml 112 113 +1
observability 21 24 +3
securitySolution 109 110 +1
triggersActionsUi 65 58 -7
total -0

ESLint disabled in files

id before after diff
@kbn/response-ops-alerts-apis - 1 +1
@kbn/response-ops-alerts-table - 2 +2
total +3

ESLint disabled line counts

id before after diff
@kbn/response-ops-alerts-fields-browser - 1 +1
@kbn/response-ops-alerts-table - 8 +8
cases 63 64 +1
observability 42 46 +4
triggersActionsUi 130 120 -10
total +4

miscellaneous assets size

id before after diff
cases 0.0B 126.3KB +126.3KB
ml 211.1KB 337.5KB +126.3KB
total +252.6KB

References to deprecated APIs

id before after diff
@kbn/response-ops-alerts-table - 15 +15
ml 57 60 +3
triggersActionsUi 27 10 -17
total +1

Total ESLint disabled count

id before after diff
@kbn/response-ops-alerts-apis - 1 +1
@kbn/response-ops-alerts-fields-browser - 1 +1
@kbn/response-ops-alerts-table - 10 +10
cases 81 82 +1
observability 43 47 +4
triggersActionsUi 135 125 -10
total +7

Unreferenced deprecated APIs

id before after diff
cases 1 0 -1

History

Copy link
Member

@cnasikas cnasikas left a comment

Choose a reason for hiding this comment

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

The ResponseOps team collectively approves.

Copy link
Contributor

@nikitaindik nikitaindik left a comment

Choose a reason for hiding this comment

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

I have reviewed the Rule Management table owned code and tested the changes on the Rule Details page. I approved on behalf of the Rule Management.

Copy link
Contributor

@js-jankisalvi js-jankisalvi left a comment

Choose a reason for hiding this comment

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

Tested alerts table in security, o11y and stack management and cases alerts tab. works as expected 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ResponseOps][Alerts] Move the alerts table into a dedicated package