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

Alerts in Correlations Part 2 #1062

Merged
merged 25 commits into from
Jun 12, 2024

Conversation

riysaxen-amzn
Copy link
Collaborator

@riysaxen-amzn riysaxen-amzn commented Jun 10, 2024

Description

  • This PR contains the APIs for alerts in Correlations:
    1). New acknowledge Correlation Alerts API
    new API signature POST /_plugins/_security_analytics/_acknowledge/correlationAlerts

    Req body: {"alerts":["4dc7f5a9-2c82-4786-81ca-433a209d5205"]}

    • The API functionality will be to update the state of correlation alert to ACKNOWLEDGED/ERROR in .opensearch-sap-correlations-alerts index depending on the success and fail of this API and update the acknowledged_time field.

GetAcknowledgeAlertsResponse API response

GetAcknowledgeAlertsResponse API response
Field | Type | Description
-- | -- | --
acknowledged | List<CorrelationAlert> | List of acknowledged correlation alerts
failed | List<CorrelationAlert> | List of failed correlation alerts

2). New API: To get/retrieve list of correlation alerts:

GET /_plugins/_security_analytics/<b>correlationAlerts

Field | Data Type | Description
-- | -- | --
severityLevel | String | Severity level of the alert
alertState | String | State of the alert
sortString | String | String used for sorting the results
sortOrder | String | Order in which the results are sorted
size | Integer | Maximum number of results recieved in the response
startIndex | Integer | The pagination indicator
searchString | String | String used for searching
correlation_rule_id | String | filter by correlation Rule

Issues Resolved

Issue

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • 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.

riysaxen-amzn and others added 20 commits March 5, 2024 10:08
Signed-off-by: Riya Saxena <[email protected]>
Signed-off-by: Riya Saxena <[email protected]>
Signed-off-by: Riya Saxena <[email protected]>
Signed-off-by: Riya Saxena <[email protected]>
Signed-off-by: Riya Saxena <[email protected]>
Signed-off-by: Riya Saxena <[email protected]>
jowg-amazon
jowg-amazon previously approved these changes Jun 11, 2024
@riysaxen-amzn
Copy link
Collaborator Author

plz add serde tests for request, response classes

will add all the tests in a seperate PR

Signed-off-by: Riya Saxena <[email protected]>
Signed-off-by: Riya Saxena <[email protected]>
Signed-off-by: Riya Saxena <[email protected]>
@eirsep
Copy link
Member

eirsep commented Jun 12, 2024

why is there not an API for list correlation alerts for all rules and only per rule id?

import static org.opensearch.action.ValidateActions.addValidationError;

public class GetCorrelationAlertsRequest extends ActionRequest {
private String correlationRuleId;
Copy link
Member

Choose a reason for hiding this comment

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

shouldnt this be a list of rule ids?


public class GetCorrelationAlertsRequest extends ActionRequest {
private String correlationRuleId;
private String correlationRuleName;
Copy link
Member

Choose a reason for hiding this comment

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

why is name required?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

right now, name is not needed because we are not using it to filter the correlation Alerts but at some point we can have a requirement to filter correlations by name, because correlation Ids will always be unique but name can be same. User can create a different correlationRules with same names, there's no correlation rule name validation

@riysaxen-amzn
Copy link
Collaborator Author

why is there not an API for list correlation alerts for all rules and only per rule id?

yeah so the API will give all the alerts if ruleId is not passed

}
Copy link
Member

Choose a reason for hiding this comment

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

revert

Copy link
Member

@eirsep eirsep left a comment

Choose a reason for hiding this comment

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

ƒew comments but LGTM from a quick scan. unit and integ tests pending

}
Copy link
Member

Choose a reason for hiding this comment

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

revert

@@ -139,119 +149,177 @@ public void indexCorrelationAlert(CorrelationAlert correlationAlert, TimeValue i
}
}

public void getCorrelationAlerts(String ruleId, Table tableProp, ActionListener<GetCorrelationAlertsResponse> listener) {
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
if (ruleId != null) {
Copy link
Member

Choose a reason for hiding this comment

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

isblank?

@riysaxen-amzn riysaxen-amzn merged commit a74f509 into opensearch-project:main Jun 12, 2024
13 of 16 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/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/security-analytics/backport-2.x
# Create a new branch
git switch --create backport-1062-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 a74f509ccbac51531b77c371550b81fcd867931a
# Push it to GitHub
git push --set-upstream origin backport-1062-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/security-analytics/backport-2.x

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

opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 12, 2024
* notification for alerting in correlation

* correlation alerts mapping change

* working code

Signed-off-by: Riya Saxena <[email protected]>

* alertsInCorrelation without notifciations

Signed-off-by: Riya Saxena <[email protected]>

* alertsInCorrelation without notifciations

Signed-off-by: Riya Saxena <[email protected]>

* alertsInCorrelation without notifciations

Signed-off-by: Riya Saxena <[email protected]>

* alerts in correlations notification service added

Signed-off-by: Riya Saxena <[email protected]>

* addressing the comments

Signed-off-by: Riya Saxena <[email protected]>

* addressing the comments

Signed-off-by: Riya Saxena <[email protected]>

* getCorrelationAlerts API changes

Signed-off-by: Riya Saxena <[email protected]>

* APIs added for Alerts in Correlations

Signed-off-by: Riya Saxena <[email protected]>

* update alerts with an errorMessage  when correlationRule is deleted

Signed-off-by: Riya Saxena <[email protected]>

* address the design changes discussed

Signed-off-by: Riya Saxena <[email protected]>

* address the design changes discussed

Signed-off-by: Riya Saxena <[email protected]>

* fixed tests

Signed-off-by: Riya Saxena <[email protected]>

* minor fixes due to merge

Signed-off-by: Riya Saxena <[email protected]>

* alerts API changes

Signed-off-by: Riya Saxena <[email protected]>

* klint fixes

Signed-off-by: Riya Saxena <[email protected]>

* license headers added

Signed-off-by: Riya Saxena <[email protected]>

* fixed format violations

Signed-off-by: Riya Saxena <[email protected]>

---------

Signed-off-by: Riya <[email protected]>
Signed-off-by: Riya Saxena <[email protected]>
(cherry picked from commit a74f509)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
riysaxen-amzn pushed a commit that referenced this pull request Jun 12, 2024
* notification for alerting in correlation

* correlation alerts mapping change

* working code



* alertsInCorrelation without notifciations



* alertsInCorrelation without notifciations



* alertsInCorrelation without notifciations



* alerts in correlations notification service added



* addressing the comments



* addressing the comments



* getCorrelationAlerts API changes



* APIs added for Alerts in Correlations



* update alerts with an errorMessage  when correlationRule is deleted



* address the design changes discussed



* address the design changes discussed



* fixed tests



* minor fixes due to merge



* alerts API changes



* klint fixes



* license headers added



* fixed format violations



---------



(cherry picked from commit a74f509)

Signed-off-by: Riya <[email protected]>
Signed-off-by: Riya Saxena <[email protected]>
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>
@riysaxen-amzn
Copy link
Collaborator Author

will address the remaining comments for this PR, in the follow up PR

jowg-amazon pushed a commit to jowg-amazon/security-analytics that referenced this pull request Jul 2, 2024
* notification for alerting in correlation

* correlation alerts mapping change

* working code

Signed-off-by: Riya Saxena <[email protected]>

* alertsInCorrelation without notifciations

Signed-off-by: Riya Saxena <[email protected]>

* alertsInCorrelation without notifciations

Signed-off-by: Riya Saxena <[email protected]>

* alertsInCorrelation without notifciations

Signed-off-by: Riya Saxena <[email protected]>

* alerts in correlations notification service added

Signed-off-by: Riya Saxena <[email protected]>

* addressing the comments

Signed-off-by: Riya Saxena <[email protected]>

* addressing the comments

Signed-off-by: Riya Saxena <[email protected]>

* getCorrelationAlerts API changes

Signed-off-by: Riya Saxena <[email protected]>

* APIs added for Alerts in Correlations

Signed-off-by: Riya Saxena <[email protected]>

* update alerts with an errorMessage  when correlationRule is deleted

Signed-off-by: Riya Saxena <[email protected]>

* address the design changes discussed

Signed-off-by: Riya Saxena <[email protected]>

* address the design changes discussed

Signed-off-by: Riya Saxena <[email protected]>

* fixed tests

Signed-off-by: Riya Saxena <[email protected]>

* minor fixes due to merge

Signed-off-by: Riya Saxena <[email protected]>

* alerts API changes

Signed-off-by: Riya Saxena <[email protected]>

* klint fixes

Signed-off-by: Riya Saxena <[email protected]>

* license headers added

Signed-off-by: Riya Saxena <[email protected]>

* fixed format violations

Signed-off-by: Riya Saxena <[email protected]>

---------

Signed-off-by: Riya <[email protected]>
Signed-off-by: Riya Saxena <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants