-
Notifications
You must be signed in to change notification settings - Fork 58
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 alert normalization #50
base: main
Are you sure you want to change the base?
Conversation
for _, t := range triggers { | ||
if trigger, ok := t.(map[string]interface{}); ok { | ||
delete(trigger, "id") | ||
|
||
if actions, ok := trigger["actions"].([]interface{}); ok { | ||
normalizeMonitorTriggerActions(actions) |
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.
Why are you removing this part of the normalization?
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.
I didn't see it present in any of the alerts that we had in our system, so it seemed spurious to keep it there. Do you want me to add it back?
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.
It was introduced here: phillbaker/terraform-provider-elasticsearch#164 can you see if that's still an issue?
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.
Checked it out and it's not an issue with the newer opensearch monitors.
The opensearch alerting plugin changes aren't using the same syntax/representation as the elasticsearch, so we can delete this without worries.
Hey @atammy-narmi we just merged the PR for provider OpenSearch 2.x support, can you please fetch upstream and modify the changes accordingly. |
OK, I've rebased the PR. |
Hey @phillbaker can we move forward with this PR? |
Hey @phillbaker just checking back, are we good to move forward with this PR? |
is there anything that's blocking this PR from being merged? |
Hey @atammy-narmi thanks for holding on this, does this change require for 2.x version of OpenSearch ? If need only for 1.x, please raise a PR to 1.x branch. Thank you |
This works with the 2.x version of opensearch 😸 |
Got it, then please change the base branch to 1.x as this an issue for only OpenSearch 1.x series. Thanks |
No, I said it's for the the 2.x branch. |
Do we need to backport this to 1.x? |
I don't think so. |
Cool, thanks LGTM. |
I don't see any tests defined for other functions in the provider_test.go, could you point to where I should add the tests? |
Hey @atammy-narmi may be it was started that way, would it be better to add in |
Hey @atammy-narmi just following back on this PR? can you please add some unit tests so that we merge this PR. |
Hey @atammy-narmi just following back again on this PR? can you please add some unit tests so that we merge this PR. |
Sorry, it will take me a couple more days, will try to get it done by next week 😄 |
@atammy-narmi Could you please create an issue and specify examples so that I can test and review the PR? |
Hey @atammy-narmi just following back on this PR? can you please add some unit tests so that we merge this PR. |
I've added something which looks like it should test this out. |
75bc90a
to
fd20db0
Compare
Should be working now. |
@@ -71,52 +94,99 @@ func testCheckOpensearchMonitorDestroy(s *terraform.State) error { | |||
return nil | |||
} | |||
|
|||
var testAccOpensearchOpenDistroMonitorJSON = ` |
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.
had to duplicate this cuz the linting was complaining if I did it the smart way by embedding the variable.
@prudhvigodithi @phillbaker @rblcoder can we move forward on this PR? |
@@ -55,17 +56,26 @@ func normalizeMonitor(tpl map[string]interface{}) { | |||
} | |||
|
|||
func normalizeMonitorTriggers(triggers []interface{}) { | |||
trigger_types := []string{"alerting_trigger", "anomaly_detector_trigger", "bucket_level_trigger", "document_level_trigger", "query_level_trigger"} | |||
for _, t := range triggers { |
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.
Just checking is there a way identify all these actions using client actions rather than hardcoding ?
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.
I see a new one chained_alert_trigger
.
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.
Sadly I don't know of any :(
Thanks @atammy-narmi other than my above two comments the change LGTM. |
@atammy-narmi @prudhvigodithi Can the code for normalizeMonitorTriggers be as follows? I checked, the tests are also passing.
|
While that seems OK with me, it seems to be relying implicitly on all triggers being named Another is that this implementation assumes only one trigger, you could potentially have multiple triggers. Removing the break and moving the normalize to inside the block should work for that scenario. |
@atammy-narmi I agree that the code above is not robust. |
Bump, can I ask whats the holdup now? |
Signed-off-by: Abhinav Tamaskar <[email protected]>
Signed-off-by: Abhinav Tamaskar <[email protected]>
Signed-off-by: Abhinav Tamaskar <[email protected]>
Signed-off-by: Abhinav Tamaskar <[email protected]>
Signed-off-by: Abhinav Tamaskar <[email protected]>
Thanks @atammy-narmi, @rblcoder since you are reviewing, can you please check and see if we are good to move forward. |
@atammy-narmi As mentioned in #50 (comment), can you try to avoid hard-coding the trigger types? |
Description
Fix normalization of alerts and triggers. The new API for opensearch rearranged the JSON so we need to update the normalization code.
I took the
trigger_types
from https://github.com/opensearch-project/alerting-dashboards-plugin/blob/353aa258fb9a2f031964427a45da765092c7cf6d/public/pages/CreateTrigger/containers/CreateTrigger/utils/constants.js#L6Issues Resolved
N/A
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.