Skip to content

Conversation

vikhy-aws
Copy link

Description

This PR adds request and response classes to common-utils to create an API that enables or disables the monitor using the following:

PUT _plugins/_alerting/monitors/{monitor_id}/enable
PUT _plugins/_alerting/monitors/{monitor_id}/disable

Related Issues

Resolves opensearch-project/alerting#1058

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

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.

}

override fun validate(): ActionRequestValidationException? {
return null
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's this function about?

Copy link
Author

Choose a reason for hiding this comment

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

It's an abstract method defined in the ActionRequest class, so need to provide an implementation here. Based on it's usage in other classes, it is used to validate the data members, which is not required in this case.

Signed-off-by: vikhy-aws <[email protected]>
Copy link
Collaborator

@AWSHurneyt AWSHurneyt left a comment

Choose a reason for hiding this comment

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

Are any changes needed in the alerting plugin interface? It may be necessary for the security analytics plugin to enable/disable monitors.
https://github.com/opensearch-project/common-utils/blob/main/src/main/kotlin/org/opensearch/commons/alerting/AlertingPluginInterface.kt

this.version = version
this.seqNo = seqNo
this.primaryTerm = primaryTerm
this.monitor = monitor
Copy link
Collaborator

Choose a reason for hiding this comment

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

We may want to consider excluding the monitor from the response. Security analytics creates per document monitors that can have thousands of queries (a.k.a., rules) in them. That can make the response size pretty big, which may be extraneous for this kind of API. Perhaps we can instead just return the updated enabled value, instead of the entire monitor? We can discuss with the team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Need an API to disable/enable monitor

3 participants