Skip to content

[Security Solution] Adds callback onUpdatePageIndex to get current pageIndex in Unified Data table#201240

Merged
logeekal merged 15 commits intoelastic:mainfrom
logeekal:fix/pagination_unified_data_table
Nov 29, 2024
Merged

[Security Solution] Adds callback onUpdatePageIndex to get current pageIndex in Unified Data table#201240
logeekal merged 15 commits intoelastic:mainfrom
logeekal:fix/pagination_unified_data_table

Conversation

@logeekal
Copy link
Copy Markdown
Contributor

@logeekal logeekal commented Nov 21, 2024

Summary

Handles resolution for

Issue - Notes fetching data for all Timeline Records

Currently, there was no way for consumer of UnifiedDataGrid to get the current pageIndex. Security Solution needs to get the current pageIndex so the items on the current page can be calculated.

@elastic/kibana-data-discovery , please let us know if you have any opinion here.

This results in notes being fetched for all Timeline Records which means minimum of 500 records and if user has queries 5000 records ( for example ), a request will be made to query notes for all those 5000 notes which leads to performance issue and sometimes error as shown below:

image

👨‍💻 Changes

This adds attribute pageIndex to timeline state.

{
    "pageIndex": number
}

pageIndex helps with getting the events for that particular page.

🟡 Caveat

  • Currently this pageIndex is shared between Query and EQL tabs which can lead to wonky behavior at time.
  • Additionally, as of now table maintains its own page index and consumer component cannot effect the pageIndex of the UnifiedDataGrid.

@logeekal logeekal added backport This PR is a backport of another PR Team:Threat Hunting:Investigations Security Solution Threat Hunting Investigations Team v8.16.2 labels Nov 21, 2024
@logeekal logeekal changed the title [Security Solution] Adds callback onChangePage to get current page Index. [Security Solution] Adds callback onChangePage to get current page Index in Unified Data table Nov 21, 2024
Copy link
Copy Markdown
Contributor

@PhilippeOberti PhilippeOberti left a comment

Choose a reason for hiding this comment

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

hey @logeekal at first glance everything worked perfectly, but doing a little more testing I noticed that as soon as we navigate to the last page and click on Load more, then everything is completely messed up:

  • the events per page returned by the new callback don't match the events rendered in the UI
  • the callback isn't being triggered at all for all the newly loaded pages

Here's a video with audio explanation on what I'm seeing locally

Screen.Recording.2024-11-21.at.4.20.31.PM.mov

@logeekal
Copy link
Copy Markdown
Contributor Author

logeekal commented Nov 22, 2024

hey @logeekal at first glance everything worked perfectly, but doing a little more testing I noticed that as soon as we navigate to the last page and click on Load more, then everything is completely messed up:

the events per page returned by the new callback don't match the events rendered in the UI
the callback isn't being triggered at all for all the newly loaded pages

I knew you will find something 👨‍🎤 .. it looks like this is something which already exists.

Raised a bug for that here : #201330

Will try to see if we can fix it in this PR itself. I think it is a small fix.

Edit

Fixed here : 1722d31

Edit

Found another bug : #201405

But let's take this one separately.

@logeekal
Copy link
Copy Markdown
Contributor Author

/ci

@logeekal
Copy link
Copy Markdown
Contributor Author

/ci

@logeekal
Copy link
Copy Markdown
Contributor Author

/ci

beforeEach(() => {
(UnifiedTimeline as unknown as jest.Mock).mockImplementation(MockUnifiedTimelineComponent);
});
it('should pass correct page rows', () => {
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.

Responsibility of collating events has been moved useTimelineEvents so this test is not needed here.

@logeekal logeekal changed the title [Security Solution] Adds callback onChangePage to get current page Index in Unified Data table [Security Solution] Adds callback onChangePage to get current pageIndex in Unified Data table Nov 22, 2024
@logeekal logeekal marked this pull request as ready for review November 22, 2024 15:34
@logeekal logeekal requested review from a team as code owners November 22, 2024 15:34
@elasticmachine
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

@PhilippeOberti PhilippeOberti left a comment

Choose a reason for hiding this comment

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

Found another issue, this time in the Correlation tab:

  • the first time we enter a query to fetch data, notes aren't being fetched
  • then when navigating between pages we do fetch notes, but the ids don't seem to match what's rendered in the view
Screen.Recording.2024-11-22.at.10.45.46.AM.mov

And checked on main and on the Correlation tab at least we are fetching all the notes for all the events. With this branch in its current state now, we are not fetching anything on first refresh, and we're fetching the wrong information when changing page...

Screen.Recording.2024-11-22.at.10.58.42.AM.mov

Let's discuss this more next week!

Copy link
Copy Markdown
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

Code-only review, Unified Data Table onChangePage change LGTM 👍

@logeekal logeekal requested a review from davismcphee November 26, 2024 14:35
@logeekal
Copy link
Copy Markdown
Contributor Author

logeekal commented Nov 26, 2024

Code-only review, Unified Data Table onChangePage change LGTM 👍

@davismcphee , I have re-requested your review as I found a bug in unified-data-table where pageIndex of pagination and pageIndex of paginationObj were not in sync because of this line. Because of this consumer was missing those updates of pageIndex.

To demonstrate the scenario in which this situation happens, see below video.

I have tried to do the sanity check of discover as well and it seems to be working fine as before. Will request you to desk-test as well.

pageIndex.bug.mp4

You can checkout the exact change here : d7f35ab

@logeekal
Copy link
Copy Markdown
Contributor Author

/ci

Copy link
Copy Markdown
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

Thanks for the updates @logeekal! It seems like there may still be a bug related to the handling of pageIndex, though.

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

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/unified-data-table 108 109 +1

Async chunks

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

id before after diff
cloudSecurityPosture 502.8KB 502.8KB -67.0B
discover 810.1KB 810.1KB -67.0B
esqlDataGrid 153.7KB 153.6KB -67.0B
securitySolution 13.4MB 13.4MB +284.0B
slo 842.7KB 842.6KB -67.0B
total +16.0B
Unknown metric groups

API count

id before after diff
@kbn/unified-data-table 184 186 +2

History

@logeekal logeekal changed the title [Security Solution] Adds callback onChangePage to get current pageIndex in Unified Data table [Security Solution] Adds callback onUpdatePageIndex to get current pageIndex in Unified Data table Nov 29, 2024
Copy link
Copy Markdown
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

Thanks for working through this with me, the latest Unified Data Table changes LGTM 👍 I'm happy we landed on a solution that's relatively straight forward and minimizes the use of effects 🙂

@logeekal logeekal merged commit de9d546 into elastic:main Nov 29, 2024
@kibanamachine
Copy link
Copy Markdown
Contributor

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

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

@kibanamachine
Copy link
Copy Markdown
Contributor

💔 All backports failed

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

You might need to backport the following PRs to 8.x:
- [React18] Migrate test suites to account for testing library upgrades security-threat-hunting-investigations (#201145)

Manual backport

To create the backport manually run:

node scripts/backport --pr 201240

Questions ?

Please refer to the Backport tool documentation

logeekal added a commit to logeekal/kibana that referenced this pull request Nov 29, 2024
…`pageIndex` in Unified Data table (elastic#201240)

## Summary

Handles resolution for
- Notes fetching data for all Timeline Records which leads to
performance issues.
- elastic#201330

## Issue - Notes fetching data for all Timeline Records

Currently, there was no way for consumer of `UnifiedDataGrid` to get the
current `pageIndex`. Security Solution needs to get the current
`pageIndex` so the items on the current page can be calculated.

@elastic/kibana-data-discovery , please let us know if you have any
opinion here.

This results in notes being fetched for all Timeline Records which means
minimum of 500 records and if user has queries 5000 records ( for
example ), a request will be made to query notes for all those 5000
notes which leads to performance issue and sometimes error as shown
below:

![image](https://github.com/user-attachments/assets/6fcfe05d-340c-4dcb-a273-5af53ed12945)

## 👨‍💻 Changes

This adds attribute `pageIndex` to timeline state.

```javascript
{
    "pageIndex": number
}
```
`pageIndex` helps with getting the events for that particular page.

## 🟡 Caveat

- Currently this `pageIndex` is shared between Query and EQL tabs which
can lead to wonky behavior at time.
- Additionally, as of now table maintains its own page index and
consumer component cannot effect the `pageIndex` of the UnifiedDataGrid.

(cherry picked from commit de9d546)

# Conflicts:
#	x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/eql/index.tsx
#	x-pack/plugins/security_solution/public/timelines/containers/index.test.tsx
logeekal added a commit to logeekal/kibana that referenced this pull request Nov 29, 2024
…`pageIndex` in Unified Data table (elastic#201240)

## Summary

Handles resolution for
- Notes fetching data for all Timeline Records which leads to
performance issues.
- elastic#201330

## Issue - Notes fetching data for all Timeline Records

Currently, there was no way for consumer of `UnifiedDataGrid` to get the
current `pageIndex`. Security Solution needs to get the current
`pageIndex` so the items on the current page can be calculated.

@elastic/kibana-data-discovery , please let us know if you have any
opinion here.

This results in notes being fetched for all Timeline Records which means
minimum of 500 records and if user has queries 5000 records ( for
example ), a request will be made to query notes for all those 5000
notes which leads to performance issue and sometimes error as shown
below:

![image](https://github.com/user-attachments/assets/6fcfe05d-340c-4dcb-a273-5af53ed12945)

## 👨‍💻 Changes

This adds attribute `pageIndex` to timeline state.

```javascript
{
    "pageIndex": number
}
```
`pageIndex` helps with getting the events for that particular page.

## 🟡 Caveat

- Currently this `pageIndex` is shared between Query and EQL tabs which
can lead to wonky behavior at time.
- Additionally, as of now table maintains its own page index and
consumer component cannot effect the `pageIndex` of the UnifiedDataGrid.

(cherry picked from commit de9d546)

# Conflicts:
#	x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/eql/index.tsx
#	x-pack/plugins/security_solution/public/timelines/containers/index.test.tsx
@logeekal
Copy link
Copy Markdown
Contributor Author

logeekal commented Nov 29, 2024

💚 All backports created successfully

Status Branch Result
8.x
8.17
8.16

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

Questions ?

Please refer to the Backport tool documentation

logeekal added a commit to logeekal/kibana that referenced this pull request Nov 29, 2024
…`pageIndex` in Unified Data table (elastic#201240)

## Summary

Handles resolution for
- Notes fetching data for all Timeline Records which leads to
performance issues.
- elastic#201330

## Issue - Notes fetching data for all Timeline Records

Currently, there was no way for consumer of `UnifiedDataGrid` to get the
current `pageIndex`. Security Solution needs to get the current
`pageIndex` so the items on the current page can be calculated.

@elastic/kibana-data-discovery , please let us know if you have any
opinion here.

This results in notes being fetched for all Timeline Records which means
minimum of 500 records and if user has queries 5000 records ( for
example ), a request will be made to query notes for all those 5000
notes which leads to performance issue and sometimes error as shown
below:

![image](https://github.com/user-attachments/assets/6fcfe05d-340c-4dcb-a273-5af53ed12945)

## 👨‍💻 Changes

This adds attribute `pageIndex` to timeline state.

```javascript
{
    "pageIndex": number
}
```
`pageIndex` helps with getting the events for that particular page.

## 🟡 Caveat

- Currently this `pageIndex` is shared between Query and EQL tabs which
can lead to wonky behavior at time.
- Additionally, as of now table maintains its own page index and
consumer component cannot effect the `pageIndex` of the UnifiedDataGrid.

(cherry picked from commit de9d546)

# Conflicts:
#	x-pack/plugins/security_solution/public/timelines/components/timeline/body/unified_timeline_body.tsx
#	x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/eql/index.tsx
#	x-pack/plugins/security_solution/public/timelines/containers/index.test.tsx
logeekal added a commit that referenced this pull request Dec 2, 2024
…rrent `pageIndex` in Unified Data table (#201240) (#202345)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Security Solution] Adds callback `onUpdatePageIndex` to get current
`pageIndex` in Unified Data table
(#201240)](#201240)

<!--- Backport version: 8.9.8 -->

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

<!--BACKPORT [{"author":{"name":"Jatin
Kathuria","email":"jatin.kathuria@elastic.co"},"sourceCommit":{"committedDate":"2024-11-29T15:14:27Z","message":"[Security
Solution] Adds callback `onUpdatePageIndex` to get current `pageIndex`
in Unified Data table (#201240)\n\n## Summary\n\nHandles resolution
for\n- Notes fetching data for all Timeline Records which leads
to\nperformance issues.\n-
#201330 \n\n## Issue - Notes
fetching data for all Timeline Records \n\nCurrently, there was no way
for consumer of `UnifiedDataGrid` to get the\ncurrent `pageIndex`.
Security Solution needs to get the current\n`pageIndex` so the items on
the current page can be calculated.\n\n@elastic/kibana-data-discovery ,
please let us know if you have any\nopinion here.\n\nThis results in
notes being fetched for all Timeline Records which means\nminimum of 500
records and if user has queries 5000 records ( for\nexample ), a request
will be made to query notes for all those 5000\nnotes which leads to
performance issue and sometimes error as
shown\nbelow:\n\n\n![image](https://github.com/user-attachments/assets/6fcfe05d-340c-4dcb-a273-5af53ed12945)\n\n\n##
👨‍💻 Changes\n\nThis adds attribute `pageIndex` to timeline state.
\n\n```javascript\n{\n \"pageIndex\": number\n}\n```\n`pageIndex` helps
with getting the events for that particular page.\n\n## 🟡 Caveat\n\n-
Currently this `pageIndex` is shared between Query and EQL tabs
which\ncan lead to wonky behavior at time.\n- Additionally, as of now
table maintains its own page index and\nconsumer component cannot effect
the `pageIndex` of the
UnifiedDataGrid.","sha":"de9d5465df5900936991d79306cb2cbbe63f4623","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["backport","release_note:fix","v9.0.0","Team:Threat
Hunting:Investigations","v8.16.2"],"number":201240,"url":"https://github.com/elastic/kibana/pull/201240","mergeCommit":{"message":"[Security
Solution] Adds callback `onUpdatePageIndex` to get current `pageIndex`
in Unified Data table (#201240)\n\n## Summary\n\nHandles resolution
for\n- Notes fetching data for all Timeline Records which leads
to\nperformance issues.\n-
#201330 \n\n## Issue - Notes
fetching data for all Timeline Records \n\nCurrently, there was no way
for consumer of `UnifiedDataGrid` to get the\ncurrent `pageIndex`.
Security Solution needs to get the current\n`pageIndex` so the items on
the current page can be calculated.\n\n@elastic/kibana-data-discovery ,
please let us know if you have any\nopinion here.\n\nThis results in
notes being fetched for all Timeline Records which means\nminimum of 500
records and if user has queries 5000 records ( for\nexample ), a request
will be made to query notes for all those 5000\nnotes which leads to
performance issue and sometimes error as
shown\nbelow:\n\n\n![image](https://github.com/user-attachments/assets/6fcfe05d-340c-4dcb-a273-5af53ed12945)\n\n\n##
👨‍💻 Changes\n\nThis adds attribute `pageIndex` to timeline state.
\n\n```javascript\n{\n \"pageIndex\": number\n}\n```\n`pageIndex` helps
with getting the events for that particular page.\n\n## 🟡 Caveat\n\n-
Currently this `pageIndex` is shared between Query and EQL tabs
which\ncan lead to wonky behavior at time.\n- Additionally, as of now
table maintains its own page index and\nconsumer component cannot effect
the `pageIndex` of the
UnifiedDataGrid.","sha":"de9d5465df5900936991d79306cb2cbbe63f4623"}},"sourceBranch":"main","suggestedTargetBranches":["8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201240","number":201240,"mergeCommit":{"message":"[Security
Solution] Adds callback `onUpdatePageIndex` to get current `pageIndex`
in Unified Data table (#201240)\n\n## Summary\n\nHandles resolution
for\n- Notes fetching data for all Timeline Records which leads
to\nperformance issues.\n-
#201330 \n\n## Issue - Notes
fetching data for all Timeline Records \n\nCurrently, there was no way
for consumer of `UnifiedDataGrid` to get the\ncurrent `pageIndex`.
Security Solution needs to get the current\n`pageIndex` so the items on
the current page can be calculated.\n\n@elastic/kibana-data-discovery ,
please let us know if you have any\nopinion here.\n\nThis results in
notes being fetched for all Timeline Records which means\nminimum of 500
records and if user has queries 5000 records ( for\nexample ), a request
will be made to query notes for all those 5000\nnotes which leads to
performance issue and sometimes error as
shown\nbelow:\n\n\n![image](https://github.com/user-attachments/assets/6fcfe05d-340c-4dcb-a273-5af53ed12945)\n\n\n##
👨‍💻 Changes\n\nThis adds attribute `pageIndex` to timeline state.
\n\n```javascript\n{\n \"pageIndex\": number\n}\n```\n`pageIndex` helps
with getting the events for that particular page.\n\n## 🟡 Caveat\n\n-
Currently this `pageIndex` is shared between Query and EQL tabs
which\ncan lead to wonky behavior at time.\n- Additionally, as of now
table maintains its own page index and\nconsumer component cannot effect
the `pageIndex` of the
UnifiedDataGrid.","sha":"de9d5465df5900936991d79306cb2cbbe63f4623"}},{"branch":"8.16","label":"v8.16.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
logeekal added a commit that referenced this pull request Dec 2, 2024
…urrent `pageIndex` in Unified Data table (#201240) (#202349)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[Security Solution] Adds callback `onUpdatePageIndex` to get current
`pageIndex` in Unified Data table
(#201240)](#201240)

<!--- Backport version: 8.9.8 -->

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

<!--BACKPORT [{"author":{"name":"Jatin
Kathuria","email":"jatin.kathuria@elastic.co"},"sourceCommit":{"committedDate":"2024-11-29T15:14:27Z","message":"[Security
Solution] Adds callback `onUpdatePageIndex` to get current `pageIndex`
in Unified Data table (#201240)\n\n## Summary\n\nHandles resolution
for\n- Notes fetching data for all Timeline Records which leads
to\nperformance issues.\n-
#201330 \n\n## Issue - Notes
fetching data for all Timeline Records \n\nCurrently, there was no way
for consumer of `UnifiedDataGrid` to get the\ncurrent `pageIndex`.
Security Solution needs to get the current\n`pageIndex` so the items on
the current page can be calculated.\n\n@elastic/kibana-data-discovery ,
please let us know if you have any\nopinion here.\n\nThis results in
notes being fetched for all Timeline Records which means\nminimum of 500
records and if user has queries 5000 records ( for\nexample ), a request
will be made to query notes for all those 5000\nnotes which leads to
performance issue and sometimes error as
shown\nbelow:\n\n\n![image](https://github.com/user-attachments/assets/6fcfe05d-340c-4dcb-a273-5af53ed12945)\n\n\n##
👨‍💻 Changes\n\nThis adds attribute `pageIndex` to timeline state.
\n\n```javascript\n{\n \"pageIndex\": number\n}\n```\n`pageIndex` helps
with getting the events for that particular page.\n\n## 🟡 Caveat\n\n-
Currently this `pageIndex` is shared between Query and EQL tabs
which\ncan lead to wonky behavior at time.\n- Additionally, as of now
table maintains its own page index and\nconsumer component cannot effect
the `pageIndex` of the
UnifiedDataGrid.","sha":"de9d5465df5900936991d79306cb2cbbe63f4623","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["backport","release_note:fix","v9.0.0","Team:Threat
Hunting:Investigations","v8.16.2"],"number":201240,"url":"https://github.com/elastic/kibana/pull/201240","mergeCommit":{"message":"[Security
Solution] Adds callback `onUpdatePageIndex` to get current `pageIndex`
in Unified Data table (#201240)\n\n## Summary\n\nHandles resolution
for\n- Notes fetching data for all Timeline Records which leads
to\nperformance issues.\n-
#201330 \n\n## Issue - Notes
fetching data for all Timeline Records \n\nCurrently, there was no way
for consumer of `UnifiedDataGrid` to get the\ncurrent `pageIndex`.
Security Solution needs to get the current\n`pageIndex` so the items on
the current page can be calculated.\n\n@elastic/kibana-data-discovery ,
please let us know if you have any\nopinion here.\n\nThis results in
notes being fetched for all Timeline Records which means\nminimum of 500
records and if user has queries 5000 records ( for\nexample ), a request
will be made to query notes for all those 5000\nnotes which leads to
performance issue and sometimes error as
shown\nbelow:\n\n\n![image](https://github.com/user-attachments/assets/6fcfe05d-340c-4dcb-a273-5af53ed12945)\n\n\n##
👨‍💻 Changes\n\nThis adds attribute `pageIndex` to timeline state.
\n\n```javascript\n{\n \"pageIndex\": number\n}\n```\n`pageIndex` helps
with getting the events for that particular page.\n\n## 🟡 Caveat\n\n-
Currently this `pageIndex` is shared between Query and EQL tabs
which\ncan lead to wonky behavior at time.\n- Additionally, as of now
table maintains its own page index and\nconsumer component cannot effect
the `pageIndex` of the
UnifiedDataGrid.","sha":"de9d5465df5900936991d79306cb2cbbe63f4623"}},"sourceBranch":"main","suggestedTargetBranches":["8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201240","number":201240,"mergeCommit":{"message":"[Security
Solution] Adds callback `onUpdatePageIndex` to get current `pageIndex`
in Unified Data table (#201240)\n\n## Summary\n\nHandles resolution
for\n- Notes fetching data for all Timeline Records which leads
to\nperformance issues.\n-
#201330 \n\n## Issue - Notes
fetching data for all Timeline Records \n\nCurrently, there was no way
for consumer of `UnifiedDataGrid` to get the\ncurrent `pageIndex`.
Security Solution needs to get the current\n`pageIndex` so the items on
the current page can be calculated.\n\n@elastic/kibana-data-discovery ,
please let us know if you have any\nopinion here.\n\nThis results in
notes being fetched for all Timeline Records which means\nminimum of 500
records and if user has queries 5000 records ( for\nexample ), a request
will be made to query notes for all those 5000\nnotes which leads to
performance issue and sometimes error as
shown\nbelow:\n\n\n![image](https://github.com/user-attachments/assets/6fcfe05d-340c-4dcb-a273-5af53ed12945)\n\n\n##
👨‍💻 Changes\n\nThis adds attribute `pageIndex` to timeline state.
\n\n```javascript\n{\n \"pageIndex\": number\n}\n```\n`pageIndex` helps
with getting the events for that particular page.\n\n## 🟡 Caveat\n\n-
Currently this `pageIndex` is shared between Query and EQL tabs
which\ncan lead to wonky behavior at time.\n- Additionally, as of now
table maintains its own page index and\nconsumer component cannot effect
the `pageIndex` of the
UnifiedDataGrid.","sha":"de9d5465df5900936991d79306cb2cbbe63f4623"}},{"branch":"8.16","label":"v8.16.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
logeekal added a commit that referenced this pull request Dec 2, 2024
…urrent `pageIndex` in Unified Data table (#201240) (#202348)

# Backport

This will backport the following commits from `main` to `8.17`:
- [[Security Solution] Adds callback `onUpdatePageIndex` to get current
`pageIndex` in Unified Data table
(#201240)](#201240)

<!--- Backport version: 8.9.8 -->

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

<!--BACKPORT [{"author":{"name":"Jatin
Kathuria","email":"jatin.kathuria@elastic.co"},"sourceCommit":{"committedDate":"2024-11-29T15:14:27Z","message":"[Security
Solution] Adds callback `onUpdatePageIndex` to get current `pageIndex`
in Unified Data table (#201240)\n\n## Summary\n\nHandles resolution
for\n- Notes fetching data for all Timeline Records which leads
to\nperformance issues.\n-
#201330 \n\n## Issue - Notes
fetching data for all Timeline Records \n\nCurrently, there was no way
for consumer of `UnifiedDataGrid` to get the\ncurrent `pageIndex`.
Security Solution needs to get the current\n`pageIndex` so the items on
the current page can be calculated.\n\n@elastic/kibana-data-discovery ,
please let us know if you have any\nopinion here.\n\nThis results in
notes being fetched for all Timeline Records which means\nminimum of 500
records and if user has queries 5000 records ( for\nexample ), a request
will be made to query notes for all those 5000\nnotes which leads to
performance issue and sometimes error as
shown\nbelow:\n\n\n![image](https://github.com/user-attachments/assets/6fcfe05d-340c-4dcb-a273-5af53ed12945)\n\n\n##
👨‍💻 Changes\n\nThis adds attribute `pageIndex` to timeline state.
\n\n```javascript\n{\n \"pageIndex\": number\n}\n```\n`pageIndex` helps
with getting the events for that particular page.\n\n## 🟡 Caveat\n\n-
Currently this `pageIndex` is shared between Query and EQL tabs
which\ncan lead to wonky behavior at time.\n- Additionally, as of now
table maintains its own page index and\nconsumer component cannot effect
the `pageIndex` of the
UnifiedDataGrid.","sha":"de9d5465df5900936991d79306cb2cbbe63f4623","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["backport","release_note:fix","v9.0.0","Team:Threat
Hunting:Investigations","v8.16.2"],"number":201240,"url":"https://github.com/elastic/kibana/pull/201240","mergeCommit":{"message":"[Security
Solution] Adds callback `onUpdatePageIndex` to get current `pageIndex`
in Unified Data table (#201240)\n\n## Summary\n\nHandles resolution
for\n- Notes fetching data for all Timeline Records which leads
to\nperformance issues.\n-
#201330 \n\n## Issue - Notes
fetching data for all Timeline Records \n\nCurrently, there was no way
for consumer of `UnifiedDataGrid` to get the\ncurrent `pageIndex`.
Security Solution needs to get the current\n`pageIndex` so the items on
the current page can be calculated.\n\n@elastic/kibana-data-discovery ,
please let us know if you have any\nopinion here.\n\nThis results in
notes being fetched for all Timeline Records which means\nminimum of 500
records and if user has queries 5000 records ( for\nexample ), a request
will be made to query notes for all those 5000\nnotes which leads to
performance issue and sometimes error as
shown\nbelow:\n\n\n![image](https://github.com/user-attachments/assets/6fcfe05d-340c-4dcb-a273-5af53ed12945)\n\n\n##
👨‍💻 Changes\n\nThis adds attribute `pageIndex` to timeline state.
\n\n```javascript\n{\n \"pageIndex\": number\n}\n```\n`pageIndex` helps
with getting the events for that particular page.\n\n## 🟡 Caveat\n\n-
Currently this `pageIndex` is shared between Query and EQL tabs
which\ncan lead to wonky behavior at time.\n- Additionally, as of now
table maintains its own page index and\nconsumer component cannot effect
the `pageIndex` of the
UnifiedDataGrid.","sha":"de9d5465df5900936991d79306cb2cbbe63f4623"}},"sourceBranch":"main","suggestedTargetBranches":["8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201240","number":201240,"mergeCommit":{"message":"[Security
Solution] Adds callback `onUpdatePageIndex` to get current `pageIndex`
in Unified Data table (#201240)\n\n## Summary\n\nHandles resolution
for\n- Notes fetching data for all Timeline Records which leads
to\nperformance issues.\n-
#201330 \n\n## Issue - Notes
fetching data for all Timeline Records \n\nCurrently, there was no way
for consumer of `UnifiedDataGrid` to get the\ncurrent `pageIndex`.
Security Solution needs to get the current\n`pageIndex` so the items on
the current page can be calculated.\n\n@elastic/kibana-data-discovery ,
please let us know if you have any\nopinion here.\n\nThis results in
notes being fetched for all Timeline Records which means\nminimum of 500
records and if user has queries 5000 records ( for\nexample ), a request
will be made to query notes for all those 5000\nnotes which leads to
performance issue and sometimes error as
shown\nbelow:\n\n\n![image](https://github.com/user-attachments/assets/6fcfe05d-340c-4dcb-a273-5af53ed12945)\n\n\n##
👨‍💻 Changes\n\nThis adds attribute `pageIndex` to timeline state.
\n\n```javascript\n{\n \"pageIndex\": number\n}\n```\n`pageIndex` helps
with getting the events for that particular page.\n\n## 🟡 Caveat\n\n-
Currently this `pageIndex` is shared between Query and EQL tabs
which\ncan lead to wonky behavior at time.\n- Additionally, as of now
table maintains its own page index and\nconsumer component cannot effect
the `pageIndex` of the
UnifiedDataGrid.","sha":"de9d5465df5900936991d79306cb2cbbe63f4623"}},{"branch":"8.16","label":"v8.16.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
…`pageIndex` in Unified Data table (elastic#201240)

## Summary

Handles resolution for
- Notes fetching data for all Timeline Records which leads to
performance issues.
- elastic#201330 

## Issue - Notes fetching data for all Timeline Records 

Currently, there was no way for consumer of `UnifiedDataGrid` to get the
current `pageIndex`. Security Solution needs to get the current
`pageIndex` so the items on the current page can be calculated.

@elastic/kibana-data-discovery , please let us know if you have any
opinion here.

This results in notes being fetched for all Timeline Records which means
minimum of 500 records and if user has queries 5000 records ( for
example ), a request will be made to query notes for all those 5000
notes which leads to performance issue and sometimes error as shown
below:


![image](https://github.com/user-attachments/assets/6fcfe05d-340c-4dcb-a273-5af53ed12945)


## 👨‍💻 Changes

This adds attribute `pageIndex` to timeline state. 

```javascript
{
    "pageIndex": number
}
```
`pageIndex` helps with getting the events for that particular page.

## 🟡 Caveat

- Currently this `pageIndex` is shared between Query and EQL tabs which
can lead to wonky behavior at time.
- Additionally, as of now table maintains its own page index and
consumer component cannot effect the `pageIndex` of the UnifiedDataGrid.
logeekal added a commit to logeekal/kibana that referenced this pull request Feb 6, 2025
…`pageIndex` in Unified Data table (elastic#201240)

## Summary

Handles resolution for
- Notes fetching data for all Timeline Records which leads to
performance issues.
- elastic#201330

## Issue - Notes fetching data for all Timeline Records

Currently, there was no way for consumer of `UnifiedDataGrid` to get the
current `pageIndex`. Security Solution needs to get the current
`pageIndex` so the items on the current page can be calculated.

@elastic/kibana-data-discovery , please let us know if you have any
opinion here.

This results in notes being fetched for all Timeline Records which means
minimum of 500 records and if user has queries 5000 records ( for
example ), a request will be made to query notes for all those 5000
notes which leads to performance issue and sometimes error as shown
below:

![image](https://github.com/user-attachments/assets/6fcfe05d-340c-4dcb-a273-5af53ed12945)

## 👨‍💻 Changes

This adds attribute `pageIndex` to timeline state.

```javascript
{
    "pageIndex": number
}
```
`pageIndex` helps with getting the events for that particular page.

## 🟡 Caveat

- Currently this `pageIndex` is shared between Query and EQL tabs which
can lead to wonky behavior at time.
- Additionally, as of now table maintains its own page index and
consumer component cannot effect the `pageIndex` of the UnifiedDataGrid.

(cherry picked from commit de9d546)

# Conflicts:
#	src/platform/packages/shared/kbn-unified-data-table/src/components/data_table.test.tsx
#	src/platform/packages/shared/kbn-unified-data-table/src/components/data_table.tsx
#	x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/eql/index.test.tsx
#	x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/tabs/eql/index.tsx
#	x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/tabs/pinned/index.tsx
#	x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/tabs/query/index.tsx
#	x-pack/solutions/security/plugins/security_solution/public/timelines/components/timeline/unified_components/data_table/index.tsx
#	x-pack/solutions/security/plugins/security_solution/public/timelines/containers/index.test.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR release_note:fix Team:Threat Hunting:Investigations Security Solution Threat Hunting Investigations Team v8.16.2 v8.17.0 v8.18.0 v9.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants