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

support list of monitor ids in Chained Monitor Findings #514

Merged
merged 4 commits into from
Aug 31, 2023

Conversation

eirsep
Copy link
Member

@eirsep eirsep commented Aug 30, 2023

Adds support for passing a list monitor ids in chained monitor findings. This helps filter data of a monitor in workflow based on findings of multiple monitors instead of a single monitor.

If workflow sequence looks like:
[m1] -> [m2] -> [m3 (chained findings of m1, m2)]
this means m3's data input would be the related doc ids from findings of m1 and m2.

for backward compatibility reasons, the monitorId field would be given preference over the new list type field, monitorIds, if both are provided.

Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
@codecov
Copy link

codecov bot commented Aug 30, 2023

Codecov Report

Merging #514 (ff2c581) into main (bae1bee) will increase coverage by 0.02%.
The diff coverage is 82.97%.

@@             Coverage Diff              @@
##               main     #514      +/-   ##
============================================
+ Coverage     74.60%   74.63%   +0.02%     
- Complexity      868      872       +4     
============================================
  Files           130      130              
  Lines          5632     5662      +30     
  Branches        689      697       +8     
============================================
+ Hits           4202     4226      +24     
- Misses         1124     1130       +6     
  Partials        306      306              
Files Changed Coverage Δ
...ch/commons/alerting/action/IndexWorkflowRequest.kt 82.02% <77.27%> (-3.51%) ⬇️
...h/commons/alerting/model/ChainedMonitorFindings.kt 85.71% <88.00%> (+5.71%) ⬆️

lezzago
lezzago previously approved these changes Aug 30, 2023
@@ -30,7 +30,7 @@ class IndexWorkflowRequest : ActionRequest {
refreshPolicy: WriteRequest.RefreshPolicy,
method: RestRequest.Method,
workflow: Workflow,
rbacRoles: List<String>? = null
rbacRoles: List<String>? = null,
Copy link
Collaborator

Choose a reason for hiding this comment

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

is the , required?

Copy link
Member Author

@eirsep eirsep Aug 31, 2023

Choose a reason for hiding this comment

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

reverted

}

@Throws(IOException::class)
constructor(sin: StreamInput) : this(
sin.readString(), // monitorId
sin.readOptionalString(), // monitorId
Collections.unmodifiableList(sin.readStringList())
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we use kotlin toList here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Any specific reason to use toList?
Collections.unmodifiableList has been used across the code base to wrap string lists read from stream input

fun asTemplateArg(): Map<String, Any> {
return mapOf(
MONITOR_ID_FIELD to monitorId,
)
MONITOR_IDS_FIELD to monitorIds
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it possible we merge these 2 fields to 1? it looks little complex that we have both

MONITOR_ID_FIELD to monitorId,
MONITOR_IDS_FIELD to monitorIds```

Copy link
Member Author

@eirsep eirsep Aug 31, 2023

Choose a reason for hiding this comment

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

we need to have both for backward compatibility.

Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
@eirsep eirsep merged commit 7736e08 into opensearch-project:main Aug 31, 2023
8 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/common-utils/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/common-utils/backport-2.x
# Create a new branch
git switch --create backport-514-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 7736e080f9b0a2f6f2d9ad3b4272090b281ea8fa
# Push it to GitHub
git push --set-upstream origin backport-514-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/common-utils/backport-2.x

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

eirsep added a commit to eirsep/common-utils that referenced this pull request Sep 1, 2023
…roject#514)

support list of monitor ids in Chained Monitor Findings

Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
eirsep added a commit that referenced this pull request Sep 1, 2023
support list of monitor ids in Chained Monitor Findings

Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
AWSHurneyt pushed a commit to AWSHurneyt/common-utils that referenced this pull request Apr 12, 2024
…roject#514) (opensearch-project#515)

support list of monitor ids in Chained Monitor Findings

Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
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