@@ -14,6 +14,7 @@ import org.opensearch.alerting.action.GetEmailGroupAction
1414import org.opensearch.alerting.action.GetRemoteIndexesAction
1515import org.opensearch.alerting.action.SearchEmailAccountAction
1616import org.opensearch.alerting.action.SearchEmailGroupAction
17+ import org.opensearch.alerting.actionv2.IndexMonitorV2Action
1718import org.opensearch.alerting.alerts.AlertIndices
1819import org.opensearch.alerting.alerts.AlertIndices.Companion.ALL_ALERT_INDEX_PATTERN
1920import org.opensearch.alerting.comments.CommentsIndices
@@ -27,6 +28,7 @@ import org.opensearch.alerting.core.resthandler.RestScheduledJobStatsHandler
2728import org.opensearch.alerting.core.schedule.JobScheduler
2829import org.opensearch.alerting.core.settings.LegacyOpenDistroScheduledJobSettings
2930import org.opensearch.alerting.core.settings.ScheduledJobSettings
31+ import org.opensearch.alerting.modelv2.MonitorV2
3032import org.opensearch.alerting.remote.monitors.RemoteMonitorRegistry
3133import org.opensearch.alerting.resthandler.RestAcknowledgeAlertAction
3234import org.opensearch.alerting.resthandler.RestAcknowledgeChainedAlertAction
@@ -51,6 +53,7 @@ import org.opensearch.alerting.resthandler.RestSearchAlertingCommentAction
5153import org.opensearch.alerting.resthandler.RestSearchEmailAccountAction
5254import org.opensearch.alerting.resthandler.RestSearchEmailGroupAction
5355import org.opensearch.alerting.resthandler.RestSearchMonitorAction
56+ import org.opensearch.alerting.resthandlerv2.RestIndexMonitorV2Action
5457import org.opensearch.alerting.script.TriggerScript
5558import org.opensearch.alerting.service.DeleteMonitorService
5659import org.opensearch.alerting.settings.AlertingSettings
@@ -83,6 +86,7 @@ import org.opensearch.alerting.transport.TransportSearchAlertingCommentAction
8386import org.opensearch.alerting.transport.TransportSearchEmailAccountAction
8487import org.opensearch.alerting.transport.TransportSearchEmailGroupAction
8588import org.opensearch.alerting.transport.TransportSearchMonitorAction
89+ import org.opensearch.alerting.transportv2.TransportIndexMonitorV2Action
8690import org.opensearch.alerting.util.DocLevelMonitorQueries
8791import org.opensearch.alerting.util.destinationmigration.DestinationMigrationCoordinator
8892import org.opensearch.cluster.metadata.IndexNameExpressionResolver
@@ -157,6 +161,7 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, R
157161 @JvmField val OPEN_SEARCH_DASHBOARDS_USER_AGENT = " OpenSearch-Dashboards"
158162 @JvmField val UI_METADATA_EXCLUDE = arrayOf(" monitor.${Monitor .UI_METADATA_FIELD } " )
159163 @JvmField val MONITOR_BASE_URI = " /_plugins/_alerting/monitors"
164+ @JvmField val MONITOR_V2_BASE_URI = " /_plugins/_alerting/v2/monitors"
160165 @JvmField val WORKFLOW_BASE_URI = " /_plugins/_alerting/workflows"
161166 @JvmField val REMOTE_BASE_URI = " /_plugins/_alerting/remote"
162167 @JvmField val DESTINATION_BASE_URI = " /_plugins/_alerting/destinations"
@@ -169,7 +174,7 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, R
169174 @JvmField val FINDING_BASE_URI = " /_plugins/_alerting/findings"
170175 @JvmField val COMMENTS_BASE_URI = " /_plugins/_alerting/comments"
171176
172- @JvmField val ALERTING_JOB_TYPES = listOf (" monitor" , " workflow" )
177+ @JvmField val ALERTING_JOB_TYPES = listOf (" monitor" , " workflow" , " monitor_v2 " )
173178 }
174179
175180 lateinit var runner: MonitorRunnerService
@@ -194,6 +199,7 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, R
194199 nodesInCluster : Supplier <DiscoveryNodes >
195200 ): List <RestHandler > {
196201 return listOf (
202+ // Alerting V1
197203 RestGetMonitorAction (),
198204 RestDeleteMonitorAction (),
199205 RestIndexMonitorAction (),
@@ -218,11 +224,15 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, R
218224 RestIndexAlertingCommentAction (),
219225 RestSearchAlertingCommentAction (),
220226 RestDeleteAlertingCommentAction (),
227+
228+ // Alerting V2
229+ RestIndexMonitorV2Action (),
221230 )
222231 }
223232
224233 override fun getActions (): List <ActionPlugin .ActionHandler <out ActionRequest , out ActionResponse >> {
225234 return listOf (
235+ // Alerting V1
226236 ActionPlugin .ActionHandler (ScheduledJobsStatsAction .INSTANCE , ScheduledJobsStatsTransportAction ::class .java),
227237 ActionPlugin .ActionHandler (AlertingActions .INDEX_MONITOR_ACTION_TYPE , TransportIndexMonitorAction ::class .java),
228238 ActionPlugin .ActionHandler (AlertingActions .GET_MONITOR_ACTION_TYPE , TransportGetMonitorAction ::class .java),
@@ -249,13 +259,17 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, R
249259 ActionPlugin .ActionHandler (AlertingActions .DELETE_COMMENT_ACTION_TYPE , TransportDeleteAlertingCommentAction ::class .java),
250260 ActionPlugin .ActionHandler (ExecuteWorkflowAction .INSTANCE , TransportExecuteWorkflowAction ::class .java),
251261 ActionPlugin .ActionHandler (GetRemoteIndexesAction .INSTANCE , TransportGetRemoteIndexesAction ::class .java),
252- ActionPlugin .ActionHandler (DocLevelMonitorFanOutAction .INSTANCE , TransportDocLevelMonitorFanOutAction ::class .java)
262+ ActionPlugin .ActionHandler (DocLevelMonitorFanOutAction .INSTANCE , TransportDocLevelMonitorFanOutAction ::class .java),
263+
264+ // Alerting V2
265+ ActionPlugin .ActionHandler (IndexMonitorV2Action .INSTANCE , TransportIndexMonitorV2Action ::class .java),
253266 )
254267 }
255268
256269 override fun getNamedXContent (): List <NamedXContentRegistry .Entry > {
257270 return listOf (
258271 Monitor .XCONTENT_REGISTRY ,
272+ MonitorV2 .XCONTENT_REGISTRY ,
259273 SearchInput .XCONTENT_REGISTRY ,
260274 DocLevelMonitorInput .XCONTENT_REGISTRY ,
261275 QueryLevelTrigger .XCONTENT_REGISTRY ,
@@ -431,7 +445,22 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, R
431445 AlertingSettings .COMMENTS_HISTORY_RETENTION_PERIOD ,
432446 AlertingSettings .COMMENTS_MAX_CONTENT_SIZE ,
433447 AlertingSettings .MAX_COMMENTS_PER_ALERT ,
434- AlertingSettings .MAX_COMMENTS_PER_NOTIFICATION
448+ AlertingSettings .MAX_COMMENTS_PER_NOTIFICATION ,
449+ AlertingSettings .ALERT_V2_HISTORY_ENABLED ,
450+ AlertingSettings .ALERT_V2_HISTORY_ROLLOVER_PERIOD ,
451+ AlertingSettings .ALERT_V2_HISTORY_INDEX_MAX_AGE ,
452+ AlertingSettings .ALERT_V2_HISTORY_MAX_DOCS ,
453+ AlertingSettings .ALERT_V2_HISTORY_RETENTION_PERIOD ,
454+ AlertingSettings .ALERTING_V2_MAX_MONITORS ,
455+ AlertingSettings .ALERTING_V2_MAX_THROTTLE_DURATION ,
456+ AlertingSettings .ALERTING_V2_MAX_EXPIRE_DURATION ,
457+ AlertingSettings .ALERTING_V2_MAX_LOOK_BACK_WINDOW ,
458+ AlertingSettings .ALERTING_V2_MAX_QUERY_LENGTH ,
459+ AlertingSettings .ALERTING_V2_QUERY_RESULTS_MAX_DATAROWS ,
460+ AlertingSettings .ALERT_V2_QUERY_RESULTS_MAX_SIZE ,
461+ AlertingSettings .ALERT_V2_PER_RESULT_TRIGGER_MAX_ALERTS ,
462+ AlertingSettings .NOTIFICATION_SUBJECT_SOURCE_MAX_LENGTH ,
463+ AlertingSettings .NOTIFICATION_MESSAGE_SOURCE_MAX_LENGTH
435464 )
436465 }
437466
@@ -449,7 +478,7 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, R
449478 return listOf (
450479 SystemIndexDescriptor (ALL_ALERT_INDEX_PATTERN , " Alerting Plugin system index pattern" ),
451480 SystemIndexDescriptor (SCHEDULED_JOBS_INDEX , " Alerting Plugin Configuration index" ),
452- SystemIndexDescriptor (ALL_COMMENTS_INDEX_PATTERN , " Alerting Comments system index pattern" )
481+ SystemIndexDescriptor (ALL_COMMENTS_INDEX_PATTERN , " Alerting Comments system index pattern" ),
453482 )
454483 }
455484
0 commit comments