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

[ML] Anomaly Explorer: Fix Anomalies Table pagination #214714

Merged
merged 15 commits into from
Mar 24, 2025

Conversation

rbrtj
Copy link
Contributor

@rbrtj rbrtj commented Mar 17, 2025

Includes a fix for #213424 and a follow up to #203224 (comment)

  • Rewrites anomalies_table in typescript
  • Decouples anomalies table state into an individual service
  • Fixes an issue where anomalies table pagination wouldn't reset to 0 after changing significant properties of the view, causing the table data to refetch

@rbrtj rbrtj self-assigned this Mar 17, 2025
@rbrtj rbrtj requested a review from a team as a code owner March 17, 2025 11:14
@rbrtj rbrtj added release_note:fix backport:prev-major Backport to (8.x, 8.18, 8.17, 8.16) the previous major branch and other branches in development backport:version Backport to applied version labels v9.1.0 :ml Team:ML Team label for ML (also use :ml) labels Mar 17, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

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

Tested in the Anomaly Explorer and SMV and LGTM

@rbrtj rbrtj requested a review from darnautov March 18, 2025 14:36
Copy link
Contributor

@darnautov darnautov 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 on the fix, and many thanks for going the extra mile in refactoring it to TypeScript! I’ve left some comments—feel free to reach out if you need any help.

Comment on lines 141 to 142
// eslint-disable-next-line no-console
console.log('Error fetching category definition for row item.', error);
Copy link
Contributor

Choose a reason for hiding this comment

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

I know you just refactored it to typescript, but I wonder if we should surface this error to the user 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we definitely shouldn't expose the error to the user, removed in 726fe10
Should we add some kind of error toast? Wdyt @darnautov?

Copy link
Contributor

Choose a reason for hiding this comment

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

Replacing the console.log with an error toast if there's an error fetching the category definition sounds a good idea.

tableDataLoading: false,
})),
catchError((error) => {
return of({ tableData: null, tableDataLoading: false });
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it ok to silently fail here?

Copy link
Contributor Author

@rbrtj rbrtj Mar 21, 2025

Choose a reason for hiding this comment

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

I believe there was no error handling previously, so I just reused the old code. However, it would be nice to handle errors here - maybe we should add some toast messages? wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

I reckon it’d be better to show an error message instead of the table in this case, especially since we want to implement the anomalies table as an embeddable. @peteharverson WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes can we show a callout rather than the table, similar to what we do (I think) with the anomaly charts and swim lane?

@rbrtj rbrtj requested a review from darnautov March 21, 2025 13:36
Copy link
Contributor

@darnautov darnautov left a comment

Choose a reason for hiding this comment

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

The fix and TS refactoring LGTM, great work on this! And good to see an enhancement with reduced API calls.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
ml 2402 2403 +1

Async chunks

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

id before after diff
ml 5.4MB 5.4MB +2.5KB

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
ml 106 107 +1

History

cc @rbrtj

@rbrtj rbrtj merged commit ab78050 into elastic:main Mar 24, 2025
9 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.16, 8.17, 8.18, 8.x

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

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Mar 24, 2025
Includes a fix for elastic#213424 and a
follow up to
elastic#203224 (comment)

* Rewrites anomalies_table in typescript
* Decouples anomalies table state into an individual service
* Fixes an issue where anomalies table pagination wouldn't reset to 0
after changing significant properties of the view, causing the table
data to refetch

(cherry picked from commit ab78050)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Mar 24, 2025
Includes a fix for elastic#213424 and a
follow up to
elastic#203224 (comment)

* Rewrites anomalies_table in typescript
* Decouples anomalies table state into an individual service
* Fixes an issue where anomalies table pagination wouldn't reset to 0
after changing significant properties of the view, causing the table
data to refetch

(cherry picked from commit ab78050)
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
8.16 Backport failed because of merge conflicts
8.17 Backport failed because of merge conflicts
8.18
8.x

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

Manual backport

To create the backport manually run:

node scripts/backport --pr 214714

Questions ?

Please refer to the Backport tool documentation

JoseLuisGJ pushed a commit to JoseLuisGJ/kibana that referenced this pull request Mar 24, 2025
Includes a fix for elastic#213424 and a
follow up to
elastic#203224 (comment)

* Rewrites anomalies_table in typescript
* Decouples anomalies table state into an individual service
* Fixes an issue where anomalies table pagination wouldn't reset to 0
after changing significant properties of the view, causing the table
data to refetch
kibanamachine added a commit that referenced this pull request Mar 24, 2025
#215669)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[ML] Anomaly Explorer: Fix Anomalies Table pagination
(#214714)](#214714)

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

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

<!--BACKPORT [{"author":{"name":"Robert
Jaszczurek","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-03-24T11:39:23Z","message":"[ML]
Anomaly Explorer: Fix Anomalies Table pagination (#214714)\n\nIncludes a
fix for #213424 and a\nfollow up
to\nhttps://github.com//pull/203224#discussion_r1875926261\n\n*
Rewrites anomalies_table in typescript\n* Decouples anomalies table
state into an individual service\n* Fixes an issue where anomalies table
pagination wouldn't reset to 0\nafter changing significant properties of
the view, causing the table\ndata to
refetch","sha":"ab780500f67b3b9f1f93ad53bfa79dcd2113f112","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix",":ml","Team:ML","backport:prev-major","backport:version","v9.1.0"],"title":"[ML]
Anomaly Explorer: Fix Anomalies Table
pagination","number":214714,"url":"https://github.com/elastic/kibana/pull/214714","mergeCommit":{"message":"[ML]
Anomaly Explorer: Fix Anomalies Table pagination (#214714)\n\nIncludes a
fix for #213424 and a\nfollow up
to\nhttps://github.com//pull/203224#discussion_r1875926261\n\n*
Rewrites anomalies_table in typescript\n* Decouples anomalies table
state into an individual service\n* Fixes an issue where anomalies table
pagination wouldn't reset to 0\nafter changing significant properties of
the view, causing the table\ndata to
refetch","sha":"ab780500f67b3b9f1f93ad53bfa79dcd2113f112"}},"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/214714","number":214714,"mergeCommit":{"message":"[ML]
Anomaly Explorer: Fix Anomalies Table pagination (#214714)\n\nIncludes a
fix for #213424 and a\nfollow up
to\nhttps://github.com//pull/203224#discussion_r1875926261\n\n*
Rewrites anomalies_table in typescript\n* Decouples anomalies table
state into an individual service\n* Fixes an issue where anomalies table
pagination wouldn't reset to 0\nafter changing significant properties of
the view, causing the table\ndata to
refetch","sha":"ab780500f67b3b9f1f93ad53bfa79dcd2113f112"}}]}]
BACKPORT-->

Co-authored-by: Robert Jaszczurek <[email protected]>
kibanamachine added a commit that referenced this pull request Mar 24, 2025
…#215670)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ML] Anomaly Explorer: Fix Anomalies Table pagination
(#214714)](#214714)

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

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

<!--BACKPORT [{"author":{"name":"Robert
Jaszczurek","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-03-24T11:39:23Z","message":"[ML]
Anomaly Explorer: Fix Anomalies Table pagination (#214714)\n\nIncludes a
fix for #213424 and a\nfollow up
to\nhttps://github.com//pull/203224#discussion_r1875926261\n\n*
Rewrites anomalies_table in typescript\n* Decouples anomalies table
state into an individual service\n* Fixes an issue where anomalies table
pagination wouldn't reset to 0\nafter changing significant properties of
the view, causing the table\ndata to
refetch","sha":"ab780500f67b3b9f1f93ad53bfa79dcd2113f112","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix",":ml","Team:ML","backport:prev-major","backport:version","v9.1.0"],"title":"[ML]
Anomaly Explorer: Fix Anomalies Table
pagination","number":214714,"url":"https://github.com/elastic/kibana/pull/214714","mergeCommit":{"message":"[ML]
Anomaly Explorer: Fix Anomalies Table pagination (#214714)\n\nIncludes a
fix for #213424 and a\nfollow up
to\nhttps://github.com//pull/203224#discussion_r1875926261\n\n*
Rewrites anomalies_table in typescript\n* Decouples anomalies table
state into an individual service\n* Fixes an issue where anomalies table
pagination wouldn't reset to 0\nafter changing significant properties of
the view, causing the table\ndata to
refetch","sha":"ab780500f67b3b9f1f93ad53bfa79dcd2113f112"}},"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/214714","number":214714,"mergeCommit":{"message":"[ML]
Anomaly Explorer: Fix Anomalies Table pagination (#214714)\n\nIncludes a
fix for #213424 and a\nfollow up
to\nhttps://github.com//pull/203224#discussion_r1875926261\n\n*
Rewrites anomalies_table in typescript\n* Decouples anomalies table
state into an individual service\n* Fixes an issue where anomalies table
pagination wouldn't reset to 0\nafter changing significant properties of
the view, causing the table\ndata to
refetch","sha":"ab780500f67b3b9f1f93ad53bfa79dcd2113f112"}}]}]
BACKPORT-->

Co-authored-by: Robert Jaszczurek <[email protected]>
cqliu1 pushed a commit to cqliu1/kibana that referenced this pull request Mar 31, 2025
Includes a fix for elastic#213424 and a
follow up to
elastic#203224 (comment)

* Rewrites anomalies_table in typescript
* Decouples anomalies table state into an individual service
* Fixes an issue where anomalies table pagination wouldn't reset to 0
after changing significant properties of the view, causing the table
data to refetch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-major Backport to (8.x, 8.18, 8.17, 8.16) the previous major branch and other branches in development backport:version Backport to applied version labels :ml release_note:fix Team:ML Team label for ML (also use :ml) v8.18.0 v8.19.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants