Skip to content

moving over data models from alerting to common-utils#227

Merged
sbcd90 merged 1 commit intoopensearch-project:mainfrom
sbcd90:alerting_integ_final
Sep 7, 2022
Merged

moving over data models from alerting to common-utils#227
sbcd90 merged 1 commit intoopensearch-project:mainfrom
sbcd90:alerting_integ_final

Conversation

@sbcd90
Copy link
Copy Markdown
Contributor

@sbcd90 sbcd90 commented Aug 30, 2022

Signed-off-by: Subhobrata Dey sbcd90@gmail.com

Description

moving over data models from alerting to common-utils.
this will help in making alerting a common framework for other plugins to be able to create and execute monitors.

Issues Resolved

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

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.

@sbcd90 sbcd90 requested a review from a team August 30, 2022 19:46
@sbcd90 sbcd90 force-pushed the alerting_integ_final branch from ef01686 to 2bad41e Compare August 30, 2022 20:05
@sbcd90 sbcd90 requested a review from getsaurabh02 August 30, 2022 20:09
@sbcd90 sbcd90 force-pushed the alerting_integ_final branch from 2bad41e to 65c9270 Compare August 30, 2022 20:13
import org.opensearch.commons.utils.BaseResponse
import org.opensearch.commons.utils.recreateObject

object AlertingPluginInterface {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: Let's add Java doc with the intent that all the transport action interfaces for Alerting Plugin should be added here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added javadoc

AlertingActions.INDEX_MONITOR_ACTION_TYPE,
request,
wrapActionListener(listener) { response ->
recreateObject(response) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is reified necessary here ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this operation is needed when making inter-plugin transport requests. Otherwise, we get into this known issue: https://discuss.elastic.co/t/how-to-share-classloader-bewteen-different-plugins/181076/6
Alerting to Notifications follow similar pattern.

)
}

@Suppress("UNCHECKED_CAST")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lets remove uncheck casting

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this check suppresses 2 warnings. So, will keep it as Alerting to Notifications follow similar pattern.

Comment on lines +48 to +61
// Ensure that trigger ids are unique within a monitor
val triggerIds = mutableSetOf<String>()
triggers.forEach { trigger ->
require(triggerIds.add(trigger.id)) { "Duplicate trigger id: ${trigger.id}. Trigger ids must be unique." }
// Verify Trigger type based on Monitor type
when (monitorType) {
MonitorType.QUERY_LEVEL_MONITOR ->
require(trigger is QueryLevelTrigger) { "Incompatible trigger [${trigger.id}] for monitor type [$monitorType]" }
MonitorType.BUCKET_LEVEL_MONITOR ->
require(trigger is BucketLevelTrigger) { "Incompatible trigger [${trigger.id}] for monitor type [$monitorType]" }
MonitorType.CLUSTER_METRICS_MONITOR ->
require(trigger is QueryLevelTrigger) { "Incompatible trigger [${trigger.id}] for monitor type [$monitorType]" }
MonitorType.DOC_LEVEL_MONITOR ->
require(trigger is DocumentLevelTrigger) { "Incompatible trigger [${trigger.id}] for monitor type [$monitorType]" }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we take an attempt and decouple the Monitor model to separate out the pojo and execution logic. That way we can have a simpler (leaner) model here, required for consumers, whole the core logic is still held by the Alerting.
This will prevent unnecessary dependencies being pulled in such as BucketLevelTriggers and BucketSelectorExt.

I am open to doing this incrementally as long we can add ToDos and open a github issue to do this as a followup

import java.io.IOException
import java.time.Instant

interface ScheduledJob : BaseModel {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Similar to previous comment, looks like some of these could be avoided if we could segregate code and structure in the monitor model

@sbcd90 sbcd90 force-pushed the alerting_integ_final branch from 65c9270 to 5f21125 Compare August 31, 2022 23:11
@sbcd90 sbcd90 force-pushed the alerting_integ_final branch from 5f21125 to dd45de0 Compare September 1, 2022 16:09
@sbcd90 sbcd90 changed the title security-analytics alerting integration via common-utils moving over data models from alerting to common-utils Sep 2, 2022
@sbcd90 sbcd90 force-pushed the alerting_integ_final branch from dd45de0 to 1f58401 Compare September 2, 2022 00:49
@lezzago
Copy link
Copy Markdown
Member

lezzago commented Sep 2, 2022

This commit should be named something not specific to security analytics. In the description, it can be mentioned this is for security analytics to use the Alerting plugin. The commit name can be like Move Alerting data models over to common-utils.

getsaurabh02
getsaurabh02 previously approved these changes Sep 7, 2022
Copy link
Copy Markdown
Member

@getsaurabh02 getsaurabh02 left a comment

Choose a reason for hiding this comment

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

Thanks @sbcd90 . Couple of notes:

  1. Lets update the intent of the PR and link with an Alerting issue - To make alerting as a common framework for other plugins to be able to create and execute monitors.
  2. Open an quick issue for refactoring if not being addressed in this PR - As the heavy objects here can be modeled as lightweight pojo to decouple the logic.

@sbcd90
Copy link
Copy Markdown
Contributor Author

sbcd90 commented Sep 7, 2022

Thanks @sbcd90 . Couple of notes:

  1. Lets update the intent of the PR and link with an Alerting issue - To make alerting as a common framework for other plugins to be able to create and execute monitors.
  2. Open an quick issue for refactoring if not being addressed in this PR - As the heavy objects here can be modeled as lightweight pojo to decouple the logic.

@sbcd90
Copy link
Copy Markdown
Contributor Author

sbcd90 commented Sep 7, 2022

This commit should be named something not specific to security analytics. In the description, it can be mentioned this is for security analytics to use the Alerting plugin. The commit name can be like Move Alerting data models over to common-utils.

  • updated commit message.

getsaurabh02
getsaurabh02 previously approved these changes Sep 7, 2022
Signed-off-by: Subhobrata Dey <sbcd90@gmail.com>
@sbcd90 sbcd90 merged commit 40290ac into opensearch-project:main Sep 7, 2022
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.

3 participants