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

[Security Solution][Data Quality Dashboard][Serverless] Fix fetchAvailableIndices in get_index_stats #197065

Merged
merged 4 commits into from
Oct 31, 2024

Conversation

kapral18
Copy link
Contributor

@kapral18 kapral18 commented Oct 21, 2024

addresses #196528

  • Remove unused get_available_indices.ts params helper file.
  • Change fetchAvailableIndices to use creation_date from _cat api instead of targeting @timestamp field of indices

UI Changes:

Before:
image
After:
image

@kapral18 kapral18 self-assigned this Oct 21, 2024
@kapral18 kapral18 requested a review from a team as a code owner October 21, 2024 13:50
@kapral18 kapral18 added backport:version Backport to applied version labels backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) v8.16.0 Team:Threat Hunting Security Solution Threat Hunting Team Team:Threat Hunting:Explore labels Oct 21, 2024
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

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

@kapral18 kapral18 added release_note:fix release_note:skip Skip the PR/issue when compiling release notes and removed release_note:fix labels Oct 21, 2024
Comment on lines 64 to 72
return {
aggregations: {
index: {
buckets: filteredIndices.map((indexInfo) => ({
key: indexInfo.index,
})),
},
},
};
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can make it simpler and return an array here, as we are no longer doing any aggregation in the query

filteredIndices.map((indexInfo) => ({
          key: indexInfo.index,
        }))

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also deploy this PR to the cloud and check it again before merge?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes also saw that after push and started simplifying. Thanks for catching tho.
I will add the label. Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@kapral18 kapral18 added the ci:project-deploy-security Create a Security Serverless Project label Oct 21, 2024
@kapral18 kapral18 force-pushed the fix/DQD/196528-fix-stats-filtering branch 4 times, most recently from 0019272 to a29630f Compare October 28, 2024 10:01
@kapral18 kapral18 requested review from semd and angorayc October 28, 2024 14:38
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.

LGTM

Copy link
Contributor

@angorayc angorayc 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 fixing this 👍 👍 👍

@kapral18 kapral18 removed v8.16.0 backport:version Backport to applied version labels labels Oct 30, 2024
kapral18 and others added 4 commits October 30, 2024 22:36
…lableIndices in get_index_stats

addresses elastic#196528

- Remove unused get_available_indices.ts params helper file.
- Change fetchAvailableIndices to use creation_date from _cat api
  instead of targeting @timestamp field of indices
…ange regardless of creation date

Previously, `fetchAvailableIndices` only considered indices whose creation dates fell within the specified date range. This missed indices that were created outside the date range but contained data within it. This fix updates the function to also include indices that have data within the specified date range by performing an additional search aggregation.

- Return back `getRequestBody` helper to build the search request for fetching indices with data in range.
- Improve error handling for invalid date formats with more specific messages.
- Update tests to reflect the new logic and error messages.
@kapral18 kapral18 force-pushed the fix/DQD/196528-fix-stats-filtering branch from a29630f to 64ea911 Compare October 30, 2024 21:38
@elasticmachine
Copy link
Contributor

elasticmachine commented Oct 30, 2024

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #70 / GenAI - Knowledge Base Entries APIs @ess Basic Security AI Assistant Knowledge Base Entries "before all" hook in "@ess Basic Security AI Assistant Knowledge Base Entries"
  • [job] [logs] FTR Configs #28 / saved objects tagging - functional tests visualize integration editing allows to assign tags to an existing visualization

Metrics [docs]

✅ unchanged

History

cc @kapral18

@kapral18 kapral18 merged commit ac013b4 into elastic:main Oct 31, 2024
25 checks passed
@kapral18 kapral18 deleted the fix/DQD/196528-fix-stats-filtering branch October 31, 2024 13:07
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

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

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 31, 2024
…lableIndices in get_index_stats (elastic#197065)

addresses elastic#196528

- Remove unused get_available_indices.ts params helper file.
- Change fetchAvailableIndices to use creation_date from _cat api
instead of targeting @timestamp field of indices

## UI Changes:

Before:

![image](https://github.com/user-attachments/assets/1954a8b6-1760-4ec7-b3d3-167b724f8b3c)
After:

![image](https://github.com/user-attachments/assets/232674a1-9691-4d49-862e-99873f22c3cf)

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit ac013b4)
@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 Oct 31, 2024
…chAvailableIndices in get_index_stats (#197065) (#198525)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Security Solution][Data Quality Dashboard][Serverless] Fix
fetchAvailableIndices in get_index_stats
(#197065)](#197065)

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

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

<!--BACKPORT [{"author":{"name":"Karen
Grigoryan","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-31T13:07:36Z","message":"[Security
Solution][Data Quality Dashboard][Serverless] Fix fetchAvailableIndices
in get_index_stats (#197065)\n\naddresses #196528\r\n\r\n- Remove unused
get_available_indices.ts params helper file.\r\n- Change
fetchAvailableIndices to use creation_date from _cat api\r\ninstead of
targeting @timestamp field of indices\r\n\r\n## UI
Changes:\r\n\r\nBefore:\r\n\r\n![image](https://github.com/user-attachments/assets/1954a8b6-1760-4ec7-b3d3-167b724f8b3c)\r\nAfter:\r\n\r\n![image](https://github.com/user-attachments/assets/232674a1-9691-4d49-862e-99873f22c3cf)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"ac013b4a99d68ac1596a19d94a7094b4284a200a","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Threat
Hunting","Team:Threat
Hunting:Explore","backport:prev-minor","ci:project-deploy-security"],"title":"[Security
Solution][Data Quality Dashboard][Serverless] Fix fetchAvailableIndices
in
get_index_stats","number":197065,"url":"https://github.com/elastic/kibana/pull/197065","mergeCommit":{"message":"[Security
Solution][Data Quality Dashboard][Serverless] Fix fetchAvailableIndices
in get_index_stats (#197065)\n\naddresses #196528\r\n\r\n- Remove unused
get_available_indices.ts params helper file.\r\n- Change
fetchAvailableIndices to use creation_date from _cat api\r\ninstead of
targeting @timestamp field of indices\r\n\r\n## UI
Changes:\r\n\r\nBefore:\r\n\r\n![image](https://github.com/user-attachments/assets/1954a8b6-1760-4ec7-b3d3-167b724f8b3c)\r\nAfter:\r\n\r\n![image](https://github.com/user-attachments/assets/232674a1-9691-4d49-862e-99873f22c3cf)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"ac013b4a99d68ac1596a19d94a7094b4284a200a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197065","number":197065,"mergeCommit":{"message":"[Security
Solution][Data Quality Dashboard][Serverless] Fix fetchAvailableIndices
in get_index_stats (#197065)\n\naddresses #196528\r\n\r\n- Remove unused
get_available_indices.ts params helper file.\r\n- Change
fetchAvailableIndices to use creation_date from _cat api\r\ninstead of
targeting @timestamp field of indices\r\n\r\n## UI
Changes:\r\n\r\nBefore:\r\n\r\n![image](https://github.com/user-attachments/assets/1954a8b6-1760-4ec7-b3d3-167b724f8b3c)\r\nAfter:\r\n\r\n![image](https://github.com/user-attachments/assets/232674a1-9691-4d49-862e-99873f22c3cf)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"ac013b4a99d68ac1596a19d94a7094b4284a200a"}}]}]
BACKPORT-->

Co-authored-by: Karen Grigoryan <[email protected]>
kapral18 added a commit to kapral18/kibana that referenced this pull request Nov 18, 2024
…lableIndices in get_index_stats (elastic#197065)

addresses elastic#196528

- Remove unused get_available_indices.ts params helper file.
- Change fetchAvailableIndices to use creation_date from _cat api
instead of targeting @timestamp field of indices

## UI Changes:

Before:

![image](https://github.com/user-attachments/assets/1954a8b6-1760-4ec7-b3d3-167b724f8b3c)
After:

![image](https://github.com/user-attachments/assets/232674a1-9691-4d49-862e-99873f22c3cf)

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit ac013b4)
@kapral18
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.16

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

Questions ?

Please refer to the Backport tool documentation

kapral18 added a commit that referenced this pull request Nov 18, 2024
…tchAvailableIndices in get_index_stats (#197065) (#200551)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[Security Solution][Data Quality Dashboard][Serverless] Fix
fetchAvailableIndices in get_index_stats
(#197065)](#197065)

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

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

<!--BACKPORT [{"author":{"name":"Karen
Grigoryan","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-31T13:07:36Z","message":"[Security
Solution][Data Quality Dashboard][Serverless] Fix fetchAvailableIndices
in get_index_stats (#197065)\n\naddresses #196528\r\n\r\n- Remove unused
get_available_indices.ts params helper file.\r\n- Change
fetchAvailableIndices to use creation_date from _cat api\r\ninstead of
targeting @timestamp field of indices\r\n\r\n## UI
Changes:\r\n\r\nBefore:\r\n\r\n![image](https://github.com/user-attachments/assets/1954a8b6-1760-4ec7-b3d3-167b724f8b3c)\r\nAfter:\r\n\r\n![image](https://github.com/user-attachments/assets/232674a1-9691-4d49-862e-99873f22c3cf)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"ac013b4a99d68ac1596a19d94a7094b4284a200a","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Threat
Hunting","Team:Threat
Hunting:Explore","backport:prev-minor","ci:project-deploy-security","v8.17.0"],"number":197065,"url":"https://github.com/elastic/kibana/pull/197065","mergeCommit":{"message":"[Security
Solution][Data Quality Dashboard][Serverless] Fix fetchAvailableIndices
in get_index_stats (#197065)\n\naddresses #196528\r\n\r\n- Remove unused
get_available_indices.ts params helper file.\r\n- Change
fetchAvailableIndices to use creation_date from _cat api\r\ninstead of
targeting @timestamp field of indices\r\n\r\n## UI
Changes:\r\n\r\nBefore:\r\n\r\n![image](https://github.com/user-attachments/assets/1954a8b6-1760-4ec7-b3d3-167b724f8b3c)\r\nAfter:\r\n\r\n![image](https://github.com/user-attachments/assets/232674a1-9691-4d49-862e-99873f22c3cf)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"ac013b4a99d68ac1596a19d94a7094b4284a200a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197065","number":197065,"mergeCommit":{"message":"[Security
Solution][Data Quality Dashboard][Serverless] Fix fetchAvailableIndices
in get_index_stats (#197065)\n\naddresses #196528\r\n\r\n- Remove unused
get_available_indices.ts params helper file.\r\n- Change
fetchAvailableIndices to use creation_date from _cat api\r\ninstead of
targeting @timestamp field of indices\r\n\r\n## UI
Changes:\r\n\r\nBefore:\r\n\r\n![image](https://github.com/user-attachments/assets/1954a8b6-1760-4ec7-b3d3-167b724f8b3c)\r\nAfter:\r\n\r\n![image](https://github.com/user-attachments/assets/232674a1-9691-4d49-862e-99873f22c3cf)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"ac013b4a99d68ac1596a19d94a7094b4284a200a"}},{"branch":"8.x","label":"v8.17.0","labelRegex":"^v8.17.0$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/198525","number":198525,"state":"MERGED","mergeCommit":{"sha":"0a561873792de54c5266884a47a0e0819dc7aea3","message":"[8.x]
[Security Solution][Data Quality Dashboard][Serverless] Fix
fetchAvailableIndices in get_index_stats (#197065) (#198525)\n\n#
Backport\n\nThis will backport the following commits from `main` to
`8.x`:\n- [[Security Solution][Data Quality Dashboard][Serverless]
Fix\nfetchAvailableIndices in
get_index_stats\n(#197065)](https://github.com/elastic/kibana/pull/197065)\n\n<!---
Backport version: 9.4.3 -->\n\n### Questions ?\nPlease refer to the
[Backport
tool\ndocumentation](https://github.com/sqren/backport)\n\n<!--BACKPORT
[{\"author\":{\"name\":\"Karen\nGrigoryan\",\"email\":\"[email protected]\"},\"sourceCommit\":{\"committedDate\":\"2024-10-31T13:07:36Z\",\"message\":\"[Security\nSolution][Data
Quality Dashboard][Serverless] Fix fetchAvailableIndices\nin
get_index_stats (#197065)\\n\\naddresses #196528\\r\\n\\r\\n- Remove
unused\nget_available_indices.ts params helper file.\\r\\n-
Change\nfetchAvailableIndices to use creation_date from _cat
api\\r\\ninstead of\ntargeting @timestamp field of indices\\r\\n\\r\\n##
UI\nChanges:\\r\\n\\r\\nBefore:\\r\\n\\r\\n![image](https://github.com/user-attachments/assets/1954a8b6-1760-4ec7-b3d3-167b724f8b3c)\\r\\nAfter:\\r\\n\\r\\n![image](https://github.com/user-attachments/assets/232674a1-9691-4d49-862e-99873f22c3cf)\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by:\nkibanamachine\n<[email protected]>\",\"sha\":\"ac013b4a99d68ac1596a19d94a7094b4284a200a\",\"branchLabelMapping\":{\"^v9.0.0$\":\"main\",\"^v8.17.0$\":\"8.x\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"release_note:skip\",\"v9.0.0\",\"Team:Threat\nHunting\",\"Team:Threat\nHunting:Explore\",\"backport:prev-minor\",\"ci:project-deploy-security\"],\"title\":\"[Security\nSolution][Data
Quality Dashboard][Serverless] Fix
fetchAvailableIndices\nin\nget_index_stats\",\"number\":197065,\"url\":\"https://github.com/elastic/kibana/pull/197065\",\"mergeCommit\":{\"message\":\"[Security\nSolution][Data
Quality Dashboard][Serverless] Fix fetchAvailableIndices\nin
get_index_stats (#197065)\\n\\naddresses #196528\\r\\n\\r\\n- Remove
unused\nget_available_indices.ts params helper file.\\r\\n-
Change\nfetchAvailableIndices to use creation_date from _cat
api\\r\\ninstead of\ntargeting @timestamp field of indices\\r\\n\\r\\n##
UI\nChanges:\\r\\n\\r\\nBefore:\\r\\n\\r\\n![image](https://github.com/user-attachments/assets/1954a8b6-1760-4ec7-b3d3-167b724f8b3c)\\r\\nAfter:\\r\\n\\r\\n![image](https://github.com/user-attachments/assets/232674a1-9691-4d49-862e-99873f22c3cf)\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by:\nkibanamachine\n<[email protected]>\",\"sha\":\"ac013b4a99d68ac1596a19d94a7094b4284a200a\"}},\"sourceBranch\":\"main\",\"suggestedTargetBranches\":[],\"targetPullRequestStates\":[{\"branch\":\"main\",\"label\":\"v9.0.0\",\"branchLabelMappingKey\":\"^v9.0.0$\",\"isSourceBranch\":true,\"state\":\"MERGED\",\"url\":\"https://github.com/elastic/kibana/pull/197065\",\"number\":197065,\"mergeCommit\":{\"message\":\"[Security\nSolution][Data
Quality Dashboard][Serverless] Fix fetchAvailableIndices\nin
get_index_stats (#197065)\\n\\naddresses #196528\\r\\n\\r\\n- Remove
unused\nget_available_indices.ts params helper file.\\r\\n-
Change\nfetchAvailableIndices to use creation_date from _cat
api\\r\\ninstead of\ntargeting @timestamp field of indices\\r\\n\\r\\n##
UI\nChanges:\\r\\n\\r\\nBefore:\\r\\n\\r\\n![image](https://github.com/user-attachments/assets/1954a8b6-1760-4ec7-b3d3-167b724f8b3c)\\r\\nAfter:\\r\\n\\r\\n![image](https://github.com/user-attachments/assets/232674a1-9691-4d49-862e-99873f22c3cf)\\r\\n\\r\\n---------\\r\\n\\r\\nCo-authored-by:\nkibanamachine\n<[email protected]>\",\"sha\":\"ac013b4a99d68ac1596a19d94a7094b4284a200a\"}}]}]\nBACKPORT-->\n\nCo-authored-by:
Karen Grigoryan <[email protected]>"}}]}] BACKPORT-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) ci:project-deploy-security Create a Security Serverless Project release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting:Explore Team:Threat Hunting Security Solution Threat Hunting Team v8.16.1 v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants