Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions alerting/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ configurations.all {
resolutionStrategy {
force "joda-time:joda-time:${versions.joda}"
force "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
force "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}"
force "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson_annotations}"
force "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${versions.jackson}"
force "com.fasterxml.jackson.dataformat:jackson-dataformat-smile:${versions.jackson}"
force "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${versions.jackson}"
force "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${versions.jackson}"
force "commons-logging:commons-logging:${versions.commonslogging}"
// force the version until OpenSearch upgrade to an invulnerable one, https://www.whitesourcesoftware.com/vulnerability-database/WS-2019-0379
force "commons-codec:commons-codec:1.13"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import org.opensearch.core.xcontent.NamedXContentRegistry
import org.opensearch.core.xcontent.XContentParser
import org.opensearch.core.xcontent.XContentParserUtils
import org.opensearch.index.query.QueryBuilders
import org.opensearch.remote.metadata.client.SdkClient
import org.opensearch.rest.RestRequest
import org.opensearch.search.builder.SearchSourceBuilder
import org.opensearch.search.fetch.subphase.FetchSourceContext
Expand All @@ -64,7 +65,8 @@ class TransportAcknowledgeAlertAction @Inject constructor(
actionFilters: ActionFilters,
val settings: Settings,
val xContentRegistry: NamedXContentRegistry,
val transportGetMonitorAction: TransportGetMonitorAction
val transportGetMonitorAction: TransportGetMonitorAction,
val sdkClient: SdkClient
) : HandledTransportAction<ActionRequest, AcknowledgeAlertResponse>(
AlertingActions.ACKNOWLEDGE_ALERTS_ACTION_NAME, transportService, actionFilters, ::AcknowledgeAlertRequest
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import org.opensearch.core.xcontent.NamedXContentRegistry
import org.opensearch.core.xcontent.XContentParser
import org.opensearch.core.xcontent.XContentParserUtils
import org.opensearch.index.query.QueryBuilders
import org.opensearch.remote.metadata.client.SdkClient
import org.opensearch.search.builder.SearchSourceBuilder
import org.opensearch.tasks.Task
import org.opensearch.transport.TransportService
Expand All @@ -69,6 +70,7 @@ class TransportAcknowledgeChainedAlertAction @Inject constructor(
actionFilters: ActionFilters,
val settings: Settings,
val xContentRegistry: NamedXContentRegistry,
val sdkClient: SdkClient,
) : HandledTransportAction<ActionRequest, AcknowledgeAlertResponse>(
AlertingActions.ACKNOWLEDGE_CHAINED_ALERTS_ACTION_NAME,
transportService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.opensearch.core.xcontent.NamedXContentRegistry
import org.opensearch.core.xcontent.XContentParser
import org.opensearch.core.xcontent.XContentParserUtils
import org.opensearch.index.query.QueryBuilders
import org.opensearch.remote.metadata.client.SdkClient
import org.opensearch.search.builder.SearchSourceBuilder
import org.opensearch.tasks.Task
import org.opensearch.transport.TransportService
Expand All @@ -52,7 +53,8 @@ class TransportDeleteAlertingCommentAction @Inject constructor(
actionFilters: ActionFilters,
val clusterService: ClusterService,
settings: Settings,
val xContentRegistry: NamedXContentRegistry
val xContentRegistry: NamedXContentRegistry,
val sdkClient: SdkClient
) : HandledTransportAction<ActionRequest, DeleteCommentResponse>(
AlertingActions.DELETE_COMMENT_ACTION_NAME, transportService, actionFilters, ::DeleteCommentRequest
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import org.opensearch.commons.utils.recreateObject
import org.opensearch.core.action.ActionListener
import org.opensearch.core.rest.RestStatus
import org.opensearch.core.xcontent.NamedXContentRegistry
import org.opensearch.remote.metadata.client.SdkClient
import org.opensearch.tasks.Task
import org.opensearch.transport.TransportService
import org.opensearch.transport.client.Client
Expand All @@ -49,7 +50,8 @@ class TransportDeleteMonitorAction @Inject constructor(
actionFilters: ActionFilters,
val clusterService: ClusterService,
settings: Settings,
val xContentRegistry: NamedXContentRegistry
val xContentRegistry: NamedXContentRegistry,
val sdkClient: SdkClient
) : HandledTransportAction<ActionRequest, DeleteMonitorResponse>(
AlertingActions.DELETE_MONITOR_ACTION_NAME, transportService, actionFilters, ::DeleteMonitorRequest
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import org.opensearch.commons.authuser.User
import org.opensearch.core.action.ActionListener
import org.opensearch.core.rest.RestStatus
import org.opensearch.core.xcontent.NamedXContentRegistry
import org.opensearch.remote.metadata.client.SdkClient
import org.opensearch.tasks.Task
import org.opensearch.transport.TransportService
import org.opensearch.transport.client.Client
Expand All @@ -56,7 +57,8 @@ class TransportExecuteMonitorAction @Inject constructor(
actionFilters: ActionFilters,
val xContentRegistry: NamedXContentRegistry,
private val docLevelMonitorQueries: DocLevelMonitorQueries,
private val settings: Settings
private val settings: Settings,
private val sdkClient: SdkClient
) : HandledTransportAction<ExecuteMonitorRequest, ExecuteMonitorResponse> (
ExecuteMonitorAction.NAME, transportService, actionFilters, ::ExecuteMonitorRequest
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import org.opensearch.core.xcontent.XContentParserUtils
import org.opensearch.index.query.BoolQueryBuilder
import org.opensearch.index.query.Operator
import org.opensearch.index.query.QueryBuilders
import org.opensearch.remote.metadata.client.SdkClient
import org.opensearch.search.builder.SearchSourceBuilder
import org.opensearch.search.sort.SortBuilders
import org.opensearch.search.sort.SortOrder
Expand All @@ -62,7 +63,8 @@ class TransportGetAlertsAction @Inject constructor(
actionFilters: ActionFilters,
val settings: Settings,
val xContentRegistry: NamedXContentRegistry,
val namedWriteableRegistry: NamedWriteableRegistry
val namedWriteableRegistry: NamedWriteableRegistry,
val sdkClient: SdkClient
) : HandledTransportAction<ActionRequest, GetAlertsResponse>(
AlertingActions.GET_ALERTS_ACTION_NAME,
transportService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import org.opensearch.core.xcontent.XContentParser
import org.opensearch.core.xcontent.XContentParserUtils
import org.opensearch.index.query.Operator
import org.opensearch.index.query.QueryBuilders
import org.opensearch.remote.metadata.client.SdkClient
import org.opensearch.search.builder.SearchSourceBuilder
import org.opensearch.search.fetch.subphase.FetchSourceContext
import org.opensearch.search.sort.SortBuilders
Expand All @@ -50,7 +51,8 @@ class TransportGetDestinationsAction @Inject constructor(
clusterService: ClusterService,
actionFilters: ActionFilters,
val settings: Settings,
val xContentRegistry: NamedXContentRegistry
val xContentRegistry: NamedXContentRegistry,
val sdkClient: SdkClient
) : HandledTransportAction<GetDestinationsRequest, GetDestinationsResponse> (
GetDestinationsAction.NAME, transportService, actionFilters, ::GetDestinationsRequest
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import org.opensearch.core.rest.RestStatus
import org.opensearch.core.xcontent.NamedXContentRegistry
import org.opensearch.index.IndexNotFoundException
import org.opensearch.index.query.QueryBuilders
import org.opensearch.remote.metadata.client.SdkClient
import org.opensearch.search.builder.SearchSourceBuilder
import org.opensearch.tasks.Task
import org.opensearch.transport.RemoteTransportException
Expand All @@ -59,6 +60,7 @@ class TransportGetMonitorAction @Inject constructor(
val xContentRegistry: NamedXContentRegistry,
val clusterService: ClusterService,
settings: Settings,
val sdkClient: SdkClient,
) : HandledTransportAction<ActionRequest, GetMonitorResponse>(
AlertingActions.GET_MONITOR_ACTION_NAME,
transportService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import org.opensearch.core.xcontent.XContentParser
import org.opensearch.core.xcontent.XContentParserUtils
import org.opensearch.index.query.Operator
import org.opensearch.index.query.QueryBuilders
import org.opensearch.remote.metadata.client.SdkClient
import org.opensearch.search.builder.SearchSourceBuilder
import org.opensearch.search.sort.SortBuilders
import org.opensearch.search.sort.SortOrder
Expand All @@ -58,6 +59,7 @@ class TransportGetWorkflowAlertsAction @Inject constructor(
actionFilters: ActionFilters,
val settings: Settings,
val xContentRegistry: NamedXContentRegistry,
val sdkClient: SdkClient,
) : HandledTransportAction<ActionRequest, GetWorkflowAlertsResponse>(
AlertingActions.GET_WORKFLOW_ALERTS_ACTION_NAME,
transportService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import org.opensearch.core.xcontent.NamedXContentRegistry
import org.opensearch.core.xcontent.XContentParser
import org.opensearch.core.xcontent.XContentParserUtils
import org.opensearch.index.query.QueryBuilders
import org.opensearch.remote.metadata.client.SdkClient
import org.opensearch.rest.RestRequest
import org.opensearch.search.builder.SearchSourceBuilder
import org.opensearch.tasks.Task
Expand All @@ -72,6 +73,7 @@ constructor(
val settings: Settings,
val xContentRegistry: NamedXContentRegistry,
val namedWriteableRegistry: NamedWriteableRegistry,
val sdkClient: SdkClient,
) : HandledTransportAction<ActionRequest, IndexCommentResponse>(
AlertingActions.INDEX_COMMENT_ACTION_NAME,
transportService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import org.opensearch.index.query.QueryBuilders
import org.opensearch.index.reindex.BulkByScrollResponse
import org.opensearch.index.reindex.DeleteByQueryAction
import org.opensearch.index.reindex.DeleteByQueryRequestBuilder
import org.opensearch.remote.metadata.client.SdkClient
import org.opensearch.rest.RestRequest
import org.opensearch.search.builder.SearchSourceBuilder
import org.opensearch.tasks.Task
Expand All @@ -101,6 +102,7 @@ class TransportIndexMonitorAction @Inject constructor(
val settings: Settings,
val xContentRegistry: NamedXContentRegistry,
val namedWriteableRegistry: NamedWriteableRegistry,
val sdkClient: SdkClient,
) : HandledTransportAction<ActionRequest, IndexMonitorResponse>(
AlertingActions.INDEX_MONITOR_ACTION_NAME, transportService, actionFilters, ::IndexMonitorRequest
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import org.opensearch.core.xcontent.XContentParser
import org.opensearch.core.xcontent.XContentParserUtils
import org.opensearch.index.query.BoolQueryBuilder
import org.opensearch.index.query.QueryBuilders
import org.opensearch.remote.metadata.client.SdkClient
import org.opensearch.search.builder.SearchSourceBuilder
import org.opensearch.tasks.Task
import org.opensearch.transport.TransportService
Expand All @@ -55,7 +56,8 @@ class TransportSearchAlertingCommentAction @Inject constructor(
val client: Client,
clusterService: ClusterService,
actionFilters: ActionFilters,
val namedWriteableRegistry: NamedWriteableRegistry
val namedWriteableRegistry: NamedWriteableRegistry,
val sdkClient: SdkClient
) : HandledTransportAction<ActionRequest, SearchResponse>(
AlertingActions.SEARCH_COMMENTS_ACTION_NAME, transportService, actionFilters, ::SearchRequest
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import org.opensearch.index.query.BoolQueryBuilder
import org.opensearch.index.query.ExistsQueryBuilder
import org.opensearch.index.query.MatchQueryBuilder
import org.opensearch.index.query.QueryBuilders
import org.opensearch.remote.metadata.client.SdkClient
import org.opensearch.search.SearchHits
import org.opensearch.search.aggregations.InternalAggregations
import org.opensearch.search.internal.InternalSearchResponse
Expand All @@ -55,7 +56,8 @@ class TransportSearchMonitorAction @Inject constructor(
val client: Client,
clusterService: ClusterService,
actionFilters: ActionFilters,
val namedWriteableRegistry: NamedWriteableRegistry
val namedWriteableRegistry: NamedWriteableRegistry,
val sdkClient: SdkClient
) : HandledTransportAction<ActionRequest, SearchResponse>(
AlertingActions.SEARCH_MONITORS_ACTION_NAME, transportService, actionFilters, ::SearchMonitorRequest
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@ class MonitorTests : OpenSearchTestCase() {
}

fun `test max triggers`() {
// Monitor no longer validates trigger count at construction time.
// Trigger count validation is now handled at the transport action level
// via the configurable MAX_TRIGGERS_PER_MONITOR setting.
val monitor = randomQueryLevelMonitor()

val tooManyTriggers = mutableListOf<Trigger>()
val manyTriggers = mutableListOf<Trigger>()
for (i in 0..10) {
tooManyTriggers.add(randomQueryLevelTrigger())
manyTriggers.add(randomQueryLevelTrigger())
}

try {
monitor.copy(triggers = tooManyTriggers)
fail("Monitor with too many triggers should be rejected.")
} catch (e: IllegalArgumentException) {
}
// Should not throw — validation moved to transport layer
val monitorWithManyTriggers = monitor.copy(triggers = manyTriggers)
assertEquals(11, monitorWithManyTriggers.triggers.size)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class IndexUtilsTests : OpenSearchTestCase() {
fun `test should update index without original version`() {
val indexContent = "{\"testIndex\":{\"settings\":{\"index\":{\"creation_date\":\"1558407515699\"," +
"\"number_of_shards\":\"1\",\"number_of_replicas\":\"1\",\"uuid\":\"t-VBBW6aR6KpJ3XP5iISOA\"," +
"\"version\":{\"created\":\"6040399\"},\"provided_name\":\"data_test\"}},\"mapping_version\":123," +
"\"version\":{\"created\":\"136317827\"},\"provided_name\":\"data_test\"}},\"mapping_version\":123," +
"\"settings_version\":123,\"aliases_version\":1,\"mappings\":{\"_doc\":{\"properties\":{\"name\":{\"type\":\"keyword\"}}}}}}"
val newMapping = "{\"_meta\":{\"schema_version\":10},\"properties\":{\"name\":{\"type\":\"keyword\"}}}"
val index: IndexMetadata = IndexMetadata.fromXContent(parser(indexContent))
Expand All @@ -65,7 +65,7 @@ class IndexUtilsTests : OpenSearchTestCase() {
fun `test should update index with lagged version`() {
val indexContent = "{\"testIndex\":{\"settings\":{\"index\":{\"creation_date\":\"1558407515699\"," +
"\"number_of_shards\":\"1\",\"number_of_replicas\":\"1\",\"uuid\":\"t-VBBW6aR6KpJ3XP5iISOA\"," +
"\"version\":{\"created\":\"6040399\"},\"provided_name\":\"data_test\"}},\"mapping_version\":123," +
"\"version\":{\"created\":\"136317827\"},\"provided_name\":\"data_test\"}},\"mapping_version\":123," +
"\"settings_version\":123,\"aliases_version\":1,\"mappings\":{\"_doc\":{\"_meta\":{\"schema_version\":1},\"properties\":" +
"{\"name\":{\"type\":\"keyword\"}}}}}}"
val newMapping = "{\"_meta\":{\"schema_version\":10},\"properties\":{\"name\":{\"type\":\"keyword\"}}}"
Expand All @@ -78,7 +78,7 @@ class IndexUtilsTests : OpenSearchTestCase() {
fun `test should update index with same version`() {
val indexContent = "{\"testIndex\":{\"settings\":{\"index\":{\"creation_date\":\"1558407515699\"," +
"\"number_of_shards\":\"1\",\"number_of_replicas\":\"1\",\"uuid\":\"t-VBBW6aR6KpJ3XP5iISOA\"," +
"\"version\":{\"created\":\"6040399\"},\"provided_name\":\"data_test\"}},\"mapping_version\":\"1\"," +
"\"version\":{\"created\":\"136317827\"},\"provided_name\":\"data_test\"}},\"mapping_version\":\"1\"," +
"\"settings_version\":\"1\",\"aliases_version\":\"1\",\"mappings\":" +
"{\"_doc\":{\"_meta\":{\"schema_version\":1},\"properties\":{\"name\":{\"type\":\"keyword\"}}}}}}"
val newMapping = "{\"_meta\":{\"schema_version\":1},\"properties\":{\"name\":{\"type\":\"keyword\"}}}"
Expand Down
Loading