-
Notifications
You must be signed in to change notification settings - Fork 76
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
fix chained findings monitor logic in update detector flow #1019
Conversation
Signed-off-by: Surya Sashank Nistala <[email protected]>
@@ -465,6 +465,18 @@ public void onResponse(Map<String, Map<String, String>> ruleFieldMappings) { | |||
new ActionListener<>() { | |||
@Override | |||
public void onResponse(Collection<IndexMonitorRequest> indexMonitorRequests) { | |||
if (detector.getRuleIdMonitorIdMap().containsKey("chained_findings_monitor")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chained_findings_monitor
should be a constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
@@ -465,6 +465,18 @@ public void onResponse(Map<String, Map<String, String>> ruleFieldMappings) { | |||
new ActionListener<>() { | |||
@Override | |||
public void onResponse(Collection<IndexMonitorRequest> indexMonitorRequests) { | |||
if (detector.getRuleIdMonitorIdMap().containsKey("chained_findings_monitor")) { | |||
String cmfId = detector.getRuleIdMonitorIdMap().get("chained_findings_monitor"); | |||
if (enabledWorkflowUsage && !indexMonitorRequests.isEmpty() && rulesById.stream().anyMatch(it -> it.getRight().isAggregationRule())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Triplicate condition + same logic on line 475. Should be refactored to a private method, something like workflowContainsAggregationRule()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
if (detector.getRuleIdMonitorIdMap().containsKey("chained_findings_monitor")) { | ||
String cmfId = detector.getRuleIdMonitorIdMap().get("chained_findings_monitor"); | ||
if (enabledWorkflowUsage && !indexMonitorRequests.isEmpty() && rulesById.stream().anyMatch(it -> it.getRight().isAggregationRule())) { | ||
//todo update not create chained findings monitor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should create and link an issue for this. Or at least elaborate on why this todo exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know why the chained monitor gets deleted in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removing TODO. its resolved
…reate constant for chained findings monitor string literal Signed-off-by: Surya Sashank Nistala <[email protected]>
f9e276a
The backport to
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.11 2.11
# Navigate to the new working tree
pushd ../.worktrees/security-analytics/backport-2.11
# Create a new branch
git switch --create backport-1019-to-2.11
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 df5f7466c3388050654af4199d6437a4a2dc2b08
# Push it to GitHub
git push --set-upstream origin backport-1019-to-2.11
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/security-analytics/backport-2.11 Then, create a pull request where the |
The backport to
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.13 2.13
# Navigate to the new working tree
pushd ../.worktrees/security-analytics/backport-2.13
# Create a new branch
git switch --create backport-1019-to-2.13
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 df5f7466c3388050654af4199d6437a4a2dc2b08
# Push it to GitHub
git push --set-upstream origin backport-1019-to-2.13
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/security-analytics/backport-2.13 Then, create a pull request where the |
* fix chained findings monitor logic in update detector flow Signed-off-by: Surya Sashank Nistala <[email protected]> * extract check for chained findings monitor into a re-usable method. create constant for chained findings monitor string literal Signed-off-by: Surya Sashank Nistala <[email protected]> --------- Signed-off-by: Surya Sashank Nistala <[email protected]> (cherry picked from commit df5f746) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…1020) * fix chained findings monitor logic in update detector flow * extract check for chained findings monitor into a re-usable method. create constant for chained findings monitor string literal --------- (cherry picked from commit df5f746) Signed-off-by: Surya Sashank Nistala <[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>
…1020) * fix chained findings monitor logic in update detector flow * extract check for chained findings monitor into a re-usable method. create constant for chained findings monitor string literal --------- (cherry picked from commit df5f746) Signed-off-by: Surya Sashank Nistala <[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> (cherry picked from commit c162a6f)
…1020) * fix chained findings monitor logic in update detector flow * extract check for chained findings monitor into a re-usable method. create constant for chained findings monitor string literal --------- (cherry picked from commit df5f746) Signed-off-by: Surya Sashank Nistala <[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> (cherry picked from commit c162a6f)
…1020) (#1023) * fix chained findings monitor logic in update detector flow * extract check for chained findings monitor into a re-usable method. create constant for chained findings monitor string literal --------- (cherry picked from commit df5f746) Signed-off-by: Surya Sashank Nistala <[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> (cherry picked from commit c162a6f) Co-authored-by: opensearch-trigger-bot[bot] <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com>
Description
Currently when updating a detector with aggegation rules, the chained finding doc levelmonitor is getting deleted
This PR fixes the logic to update/retain the chained finding doc level monitor
Added to integ test to verify detector behaviour after updating detector.