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

Fix get alerts api to also return chained alerts with default params. and skip audit state alerts #1020

Merged
merged 3 commits into from
Jul 13, 2023

Conversation

eirsep
Copy link
Member

@eirsep eirsep commented Jul 13, 2023

Fix get alerts api to also return chained alerts with default params. and skip audit state alerts
If audit state alerts are required, need to pass monitor id, workflow id and state=audit in params.

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.

@eirsep eirsep added the backport 2.9 backports PRs to 2.9 label Jul 13, 2023
…kip audit alerts

Signed-off-by: Surya Sashank Nistala <[email protected]>
Comment on lines +104 to +105
// But if the API is called with query_params: state=AUDIT,monitor_id=<123>,workflow_id=<abc>, this api
// will return audit alerts generated by delegate monitor <123> in workflow <abc>
Copy link
Member

@lezzago lezzago Jul 13, 2023

Choose a reason for hiding this comment

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

If we are still letting this API call get audit alerts, it should be included in ALL. It should not be just for the dashboard use case.

Otherwise, we should not let users see audit alerts through this API and only from the workflow alerts API

Copy link
Member

Choose a reason for hiding this comment

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

If not supporting it in ALL is temporary until the front end can fix it, then I am fine with going with this logic as long as we have an open github issue about it

Copy link
Member Author

Choose a reason for hiding this comment

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

AUDIT alerts is a state designed to ållow us to create events which we don't want to get users notified about. That's why they rely on chained alerts to be actionable(notifications/acknowledgement etc)

When we return alerts in the api it would clutter the response.

Copy link
Member Author

Choose a reason for hiding this comment

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

Created issue to discuss further and reconcile with front end #1021

Copy link
Member

Choose a reason for hiding this comment

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

I think we should make a call on if we want audit alerts here or not now.

@@ -107,16 +115,23 @@ class TransportGetAlertsAction @Inject constructor(

if (getAlertsRequest.monitorId != null) {
queryBuilder.filter(QueryBuilders.termQuery("monitor_id", getAlertsRequest.monitorId))
if (getAlertsRequest.workflowIds.isNullOrEmpty()) {
val noWorklfowIdQuery = QueryBuilders.boolQuery()
Copy link
Member

Choose a reason for hiding this comment

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

noWorklfowIdQuery is misspelled.

Copy link
Member Author

Choose a reason for hiding this comment

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

corrected

@@ -310,7 +310,7 @@ object CompositeWorkflowRunner : WorkflowRunner() {
.should(boolQuery().mustNot(existsQuery(Alert.ERROR_MESSAGE_FIELD)))
.should(termsQuery(Alert.ERROR_MESSAGE_FIELD, ""))
queryBuilder.must(noErrorQuery)
searchRequest.source().query(queryBuilder)
searchRequest.source().query(queryBuilder).size(9999)
Copy link
Member

Choose a reason for hiding this comment

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

why?

Copy link
Member Author

Choose a reason for hiding this comment

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

to make sure we fetch as many alerts as we can
we don't intend to evaluate with just 10 alerts which the default if no size is mentioned

Copy link
Member

Choose a reason for hiding this comment

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

We should be paginating through them then. Also isnt there a max of 25 delegate monitors to a workflow?

Copy link
Member Author

Choose a reason for hiding this comment

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

let's revisit this soon
#1022 and take a quick follow up.

…lerts and fetch only chained alerts

Signed-off-by: Surya Sashank Nistala <[email protected]>
@codecov
Copy link

codecov bot commented Jul 13, 2023

Codecov Report

Merging #1020 (de80840) into 2.x (3ba65f2) will increase coverage by 0.04%.
The diff coverage is 90.90%.

@@             Coverage Diff              @@
##                2.x    #1020      +/-   ##
============================================
+ Coverage     72.56%   72.60%   +0.04%     
  Complexity      119      119              
============================================
  Files           160      160              
  Lines         10424    10434      +10     
  Branches       1569     1571       +2     
============================================
+ Hits           7564     7576      +12     
+ Misses         1971     1964       -7     
- Partials        889      894       +5     
Impacted Files Coverage Δ
...rch/alerting/transport/TransportGetAlertsAction.kt 73.98% <85.71%> (+0.07%) ⬆️
.../org/opensearch/alerting/MonitorMetadataService.kt 64.92% <100.00%> (ø)
...ting/transport/TransportGetWorkflowAlertsAction.kt 66.66% <100.00%> (+0.59%) ⬆️
...earch/alerting/workflow/CompositeWorkflowRunner.kt 70.76% <100.00%> (+0.51%) ⬆️

... and 6 files with indirect coverage changes

Signed-off-by: Surya Sashank Nistala <[email protected]>
@lezzago
Copy link
Member

lezzago commented Jul 13, 2023

Approving for now, but we have to follow up on these issues called out.

  1. If audit alerts should be retrieved in the get Alerts API (Revisit how get alerts API deals with AUDIT state alerts  #1021) (@mnkugler)
  2. Pagination on fetching alerts for workflow

@eirsep eirsep merged commit 0add91f into opensearch-project:2.x Jul 13, 2023
12 of 16 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jul 13, 2023
… and skip audit state alerts (#1020)

* fix get alerts api with default params to return chained alerts and skip audit alerts

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix alert state query filter for get workflow alerts to avoid audit alerts and fetch only chained alerts

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix typo

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>
(cherry picked from commit 0add91f)
eirsep added a commit that referenced this pull request Jul 13, 2023
… and skip audit state alerts (#1020) (#1023)

* fix get alerts api with default params to return chained alerts and skip audit alerts

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix alert state query filter for get workflow alerts to avoid audit alerts and fetch only chained alerts

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix typo

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>
(cherry picked from commit 0add91f)

Co-authored-by: Surya Sashank Nistala <[email protected]>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jul 26, 2023
… and skip audit state alerts (#1020)

* fix get alerts api with default params to return chained alerts and skip audit alerts

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix alert state query filter for get workflow alerts to avoid audit alerts and fetch only chained alerts

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix typo

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>
(cherry picked from commit 0add91f)
lezzago pushed a commit that referenced this pull request Jul 26, 2023
… and skip audit state alerts (#1020) (#1056)

* fix get alerts api with default params to return chained alerts and skip audit alerts

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix alert state query filter for get workflow alerts to avoid audit alerts and fetch only chained alerts

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix typo

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>
(cherry picked from commit 0add91f)

Co-authored-by: Surya Sashank Nistala <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport main backport 2.9 backports PRs to 2.9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants