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

Fixed logic to get all alerts for a detector #965

Merged

Conversation

amsiglan
Copy link
Collaborator

Description

The total_alerts count of getAlerts API is capped at 10000, so we cannot rely on that count to find the total number of alerts. As a mitigation, the logic has been refactored to fetch alerts until we get less than 10k alerts which would mean there are no more alerts remaining.

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>
const alertsPromisesRes = await Promise.allSettled(getAlertsPromises);
startIndex += alertsCount;
} while (
// If we get 10,000 alerts as part of the previous call then there might be more alerts to fetch,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not blocking, but can we create an issue in the alerting/SAP backend repo to track fixing the getAlerts API response, and provide a link to that issue in this comment? That will help track when we should refactor this frontend code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@riysaxen-amzn Can you create an issue in backend and reference this PR there? Thanks!

Copy link
Collaborator

@AWSHurneyt AWSHurneyt left a comment

Choose a reason for hiding this comment

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

Changes LGTM; approving assuming CI passes.

@amsiglan
Copy link
Collaborator Author

UTs passed locally -
image

Copy link

codecov bot commented Mar 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 31.24%. Comparing base (4faedfe) to head (2a51e46).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #965      +/-   ##
==========================================
- Coverage   31.25%   31.24%   -0.01%     
==========================================
  Files         159      159              
  Lines        5283     5278       -5     
  Branches      981      980       -1     
==========================================
- Hits         1651     1649       -2     
+ Misses       3458     3455       -3     
  Partials      174      174              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@amsiglan amsiglan merged commit 03d3b14 into opensearch-project:main Mar 22, 2024
10 of 14 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/security-analytics-dashboards-plugin/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/security-analytics-dashboards-plugin/backport-2.x
# Create a new branch
git switch --create backport-965-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 03d3b1494f55dbc57934970ab80db3dbe0239fa3
# Push it to GitHub
git push --set-upstream origin backport-965-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/security-analytics-dashboards-plugin/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport-965-to-2.x.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.13 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/security-analytics-dashboards-plugin/backport-2.13 2.13
# Navigate to the new working tree
pushd ../.worktrees/security-analytics-dashboards-plugin/backport-2.13
# Create a new branch
git switch --create backport-965-to-2.13
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 03d3b1494f55dbc57934970ab80db3dbe0239fa3
# Push it to GitHub
git push --set-upstream origin backport-965-to-2.13
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/security-analytics-dashboards-plugin/backport-2.13

Then, create a pull request where the base branch is 2.13 and the compare/head branch is backport-965-to-2.13.

amsiglan added a commit to amsiglan/security-analytics-dashboards-plugin that referenced this pull request Mar 22, 2024
Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>
amsiglan added a commit that referenced this pull request Mar 22, 2024
* Rule editor enhancements (#924)

* rule editor enhancements

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* updated test snapshots

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* relax validation for author name and description

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* added validation for level, status, log type in yaml editor

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* fix rule creation with empty or undefined Id

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* fixed cypress tests

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

---------

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* Fetch all findings and alerts for the detectors when displaying in the tables (#942)

* fetching all findings using the pagination query params; optimized api calls for alert flyout, correlations

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* fetching all alerts; updated correlations UI

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* addressed PR comments; updated snapshots

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

---------

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* fixed logic to get all alerts (#965)

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

---------

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Mar 22, 2024
* Rule editor enhancements (#924)

* rule editor enhancements

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* updated test snapshots

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* relax validation for author name and description

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* added validation for level, status, log type in yaml editor

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* fix rule creation with empty or undefined Id

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* fixed cypress tests

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

---------

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* Fetch all findings and alerts for the detectors when displaying in the tables (#942)

* fetching all findings using the pagination query params; optimized api calls for alert flyout, correlations

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* fetching all alerts; updated correlations UI

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* addressed PR comments; updated snapshots

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

---------

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

* fixed logic to get all alerts (#965)

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>

---------

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>
(cherry picked from commit a683e9c)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
amsiglan pushed a commit that referenced this pull request Mar 22, 2024
* Rule editor enhancements (#924)

* rule editor enhancements



* updated test snapshots



* relax validation for author name and description



* added validation for level, status, log type in yaml editor



* fix rule creation with empty or undefined Id



* fixed cypress tests



---------



* Fetch all findings and alerts for the detectors when displaying in the tables (#942)

* fetching all findings using the pagination query params; optimized api calls for alert flyout, correlations



* fetching all alerts; updated correlations UI



* addressed PR comments; updated snapshots



---------



* fixed logic to get all alerts (#965)



---------


(cherry picked from commit a683e9c)

Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@amsiglan amsiglan added backport 2.12 backport 2.11 PRs to be backported to 2.11 branch labels Apr 10, 2024
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.11 failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/security-analytics-dashboards-plugin/backport-2.11 2.11
# Navigate to the new working tree
pushd ../.worktrees/security-analytics-dashboards-plugin/backport-2.11
# Create a new branch
git switch --create backport-965-to-2.11
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 03d3b1494f55dbc57934970ab80db3dbe0239fa3
# Push it to GitHub
git push --set-upstream origin backport-965-to-2.11
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/security-analytics-dashboards-plugin/backport-2.11

Then, create a pull request where the base branch is 2.11 and the compare/head branch is backport-965-to-2.11.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.12 failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/security-analytics-dashboards-plugin/backport-2.12 2.12
# Navigate to the new working tree
pushd ../.worktrees/security-analytics-dashboards-plugin/backport-2.12
# Create a new branch
git switch --create backport-965-to-2.12
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 03d3b1494f55dbc57934970ab80db3dbe0239fa3
# Push it to GitHub
git push --set-upstream origin backport-965-to-2.12
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/security-analytics-dashboards-plugin/backport-2.12

Then, create a pull request where the base branch is 2.12 and the compare/head branch is backport-965-to-2.12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x backport 2.11 PRs to be backported to 2.11 branch backport 2.12 backport 2.13 Triggers backport to 2.13 branch failed backport
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants