moving over data models from alerting to common-utils#227
moving over data models from alerting to common-utils#227sbcd90 merged 1 commit intoopensearch-project:mainfrom
Conversation
ef01686 to
2bad41e
Compare
2bad41e to
65c9270
Compare
| import org.opensearch.commons.utils.BaseResponse | ||
| import org.opensearch.commons.utils.recreateObject | ||
|
|
||
| object AlertingPluginInterface { |
There was a problem hiding this comment.
nit: Let's add Java doc with the intent that all the transport action interfaces for Alerting Plugin should be added here.
| AlertingActions.INDEX_MONITOR_ACTION_TYPE, | ||
| request, | ||
| wrapActionListener(listener) { response -> | ||
| recreateObject(response) { |
There was a problem hiding this comment.
is reified necessary here ?
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
lets remove uncheck casting
There was a problem hiding this comment.
this check suppresses 2 warnings. So, will keep it as Alerting to Notifications follow similar pattern.
| // 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]" } |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Similar to previous comment, looks like some of these could be avoided if we could segregate code and structure in the monitor model
65c9270 to
5f21125
Compare
5f21125 to
dd45de0
Compare
dd45de0 to
1f58401
Compare
|
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 |
getsaurabh02
left a comment
There was a problem hiding this comment.
Thanks @sbcd90 . Couple of notes:
- 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.
- 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.
1f58401 to
2b03f87
Compare
|
|
Signed-off-by: Subhobrata Dey <sbcd90@gmail.com>
2b03f87 to
aa15e70
Compare
Signed-off-by: Subhobrata Dey sbcd90@gmail.com
Description
moving over data models from
alertingtocommon-utils.this will help in making
alertinga common framework for other plugins to be able to create and execute monitors.Issues Resolved
Check List
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.