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
7 changes: 0 additions & 7 deletions alerting/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,7 @@ 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 Expand Up @@ -177,8 +172,6 @@ dependencies {
implementation "com.github.seancfoley:ipaddress:5.4.1"
implementation project(path: ":alerting-spi", configuration: 'shadow')

implementation "org.opensearch:opensearch-remote-metadata-sdk:${opensearch_build}"

testImplementation "org.antlr:antlr4-runtime:${versions.antlr4}"
testImplementation "org.jetbrains.kotlin:kotlin-test:${kotlin_version}"
testImplementation "org.mockito:mockito-core:${versions.mockito}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ import org.opensearch.alerting.script.TriggerScript
import org.opensearch.alerting.service.DeleteMonitorService
import org.opensearch.alerting.settings.AlertingSettings
import org.opensearch.alerting.settings.AlertingSettings.Companion.DOC_LEVEL_MONITOR_SHARD_FETCH_SIZE
import org.opensearch.alerting.settings.AlertingSettings.Companion.MULTI_TENANCY_ENABLED
import org.opensearch.alerting.settings.AlertingSettings.Companion.REMOTE_METADATA_ENDPOINT
import org.opensearch.alerting.settings.AlertingSettings.Companion.REMOTE_METADATA_REGION
import org.opensearch.alerting.settings.AlertingSettings.Companion.REMOTE_METADATA_SERVICE_NAME
import org.opensearch.alerting.settings.AlertingSettings.Companion.REMOTE_METADATA_STORE_TYPE
import org.opensearch.alerting.settings.DestinationSettings
import org.opensearch.alerting.settings.LegacyOpenDistroAlertingSettings
import org.opensearch.alerting.settings.LegacyOpenDistroDestinationSettings
Expand Down Expand Up @@ -134,13 +129,6 @@ import org.opensearch.plugins.ReloadablePlugin
import org.opensearch.plugins.ScriptPlugin
import org.opensearch.plugins.SearchPlugin
import org.opensearch.plugins.SystemIndexPlugin
import org.opensearch.remote.metadata.client.SdkClient
import org.opensearch.remote.metadata.client.impl.SdkClientFactory
import org.opensearch.remote.metadata.common.CommonValue.REMOTE_METADATA_ENDPOINT_KEY
import org.opensearch.remote.metadata.common.CommonValue.REMOTE_METADATA_REGION_KEY
import org.opensearch.remote.metadata.common.CommonValue.REMOTE_METADATA_SERVICE_NAME_KEY
import org.opensearch.remote.metadata.common.CommonValue.REMOTE_METADATA_TYPE_KEY
import org.opensearch.remote.metadata.common.CommonValue.TENANT_AWARE_KEY
import org.opensearch.repositories.RepositoriesService
import org.opensearch.rest.RestController
import org.opensearch.rest.RestHandler
Expand Down Expand Up @@ -337,19 +325,6 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, R
this.threadPool = threadPool
this.clusterService = clusterService

val sdkClient: SdkClient = SdkClientFactory.createSdkClient(
client,
xContentRegistry,
mapOf(
REMOTE_METADATA_TYPE_KEY to REMOTE_METADATA_STORE_TYPE.get(settings),
REMOTE_METADATA_ENDPOINT_KEY to REMOTE_METADATA_ENDPOINT.get(settings),
REMOTE_METADATA_REGION_KEY to REMOTE_METADATA_REGION.get(settings),
REMOTE_METADATA_SERVICE_NAME_KEY to REMOTE_METADATA_SERVICE_NAME.get(settings),
TENANT_AWARE_KEY to MULTI_TENANCY_ENABLED.get(settings).toString()
),
client.threadPool().executor(ThreadPool.Names.GENERIC)
)

MonitorMetadataService.initialize(
client,
clusterService,
Expand All @@ -376,8 +351,7 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, R
destinationMigrationCoordinator,
lockService,
alertService,
triggerService,
sdkClient
triggerService
)
}

Expand Down Expand Up @@ -459,12 +433,7 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, R
AlertingSettings.COMMENTS_MAX_CONTENT_SIZE,
AlertingSettings.MAX_COMMENTS_PER_ALERT,
AlertingSettings.MAX_COMMENTS_PER_NOTIFICATION,
AlertingSettings.NOTIFICATION_CONTEXT_RESULTS_ALLOWED_ROLES,
AlertingSettings.MULTI_TENANCY_ENABLED,
AlertingSettings.REMOTE_METADATA_STORE_TYPE,
AlertingSettings.REMOTE_METADATA_ENDPOINT,
AlertingSettings.REMOTE_METADATA_REGION,
AlertingSettings.REMOTE_METADATA_SERVICE_NAME
AlertingSettings.NOTIFICATION_CONTEXT_RESULTS_ALLOWED_ROLES
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ package org.opensearch.alerting.settings
import org.opensearch.alerting.AlertingPlugin
import org.opensearch.common.settings.Setting
import org.opensearch.common.unit.TimeValue
import org.opensearch.remote.metadata.common.CommonValue.REMOTE_METADATA_ENDPOINT_KEY
import org.opensearch.remote.metadata.common.CommonValue.REMOTE_METADATA_REGION_KEY
import org.opensearch.remote.metadata.common.CommonValue.REMOTE_METADATA_SERVICE_NAME_KEY
import org.opensearch.remote.metadata.common.CommonValue.REMOTE_METADATA_TYPE_KEY
import java.util.concurrent.TimeUnit
import java.util.function.Function

Expand All @@ -23,7 +19,6 @@ class AlertingSettings {
companion object {
const val DEFAULT_MAX_ACTIONABLE_ALERT_COUNT = 50L
const val DEFAULT_FINDINGS_INDEXING_BATCH_SIZE = 1000
private const val REMOTE_METADATA_KEY_PREFIX = "plugins.alerting"
const val DEFAULT_PERCOLATE_QUERY_NUM_DOCS_IN_MEMORY = 50000
const val DEFAULT_PERCOLATE_QUERY_DOCS_SIZE_MEMORY_PERCENTAGE_LIMIT = 10
const val DEFAULT_DOC_LEVEL_MONITOR_SHARD_FETCH_SIZE = 10000
Expand Down Expand Up @@ -316,36 +311,5 @@ class AlertingSettings {
Setting.Property.NodeScope,
Setting.Property.Dynamic
)

val MULTI_TENANCY_ENABLED: Setting<Boolean> = Setting.boolSetting(
"$REMOTE_METADATA_KEY_PREFIX.multi_tenancy_enabled",
false,
Setting.Property.NodeScope,
Setting.Property.Final
)

val REMOTE_METADATA_STORE_TYPE: Setting<String?> = Setting.simpleString(
"$REMOTE_METADATA_KEY_PREFIX.$REMOTE_METADATA_TYPE_KEY",
Setting.Property.NodeScope,
Setting.Property.Final
)

val REMOTE_METADATA_ENDPOINT: Setting<String?> = Setting.simpleString(
"$REMOTE_METADATA_KEY_PREFIX.$REMOTE_METADATA_ENDPOINT_KEY",
Setting.Property.NodeScope,
Setting.Property.Final
)

val REMOTE_METADATA_REGION: Setting<String?> = Setting.simpleString(
"$REMOTE_METADATA_KEY_PREFIX.$REMOTE_METADATA_REGION_KEY",
Setting.Property.NodeScope,
Setting.Property.Final
)

val REMOTE_METADATA_SERVICE_NAME: Setting<String?> = Setting.simpleString(
"$REMOTE_METADATA_KEY_PREFIX.$REMOTE_METADATA_SERVICE_NAME_KEY",
Setting.Property.NodeScope,
Setting.Property.Final
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ 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 @@ -65,8 +64,7 @@ class TransportAcknowledgeAlertAction @Inject constructor(
actionFilters: ActionFilters,
val settings: Settings,
val xContentRegistry: NamedXContentRegistry,
val transportGetMonitorAction: TransportGetMonitorAction,
val sdkClient: SdkClient
val transportGetMonitorAction: TransportGetMonitorAction
) : 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,7 +52,6 @@ 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 @@ -70,7 +69,6 @@ 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,7 +38,6 @@ 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 @@ -53,8 +52,7 @@ class TransportDeleteAlertingCommentAction @Inject constructor(
actionFilters: ActionFilters,
val clusterService: ClusterService,
settings: Settings,
val xContentRegistry: NamedXContentRegistry,
val sdkClient: SdkClient
val xContentRegistry: NamedXContentRegistry
) : 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,7 +36,6 @@ 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 @@ -50,8 +49,7 @@ class TransportDeleteMonitorAction @Inject constructor(
actionFilters: ActionFilters,
val clusterService: ClusterService,
settings: Settings,
val xContentRegistry: NamedXContentRegistry,
val sdkClient: SdkClient
val xContentRegistry: NamedXContentRegistry
) : 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,7 +39,6 @@ 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 @@ -57,8 +56,7 @@ class TransportExecuteMonitorAction @Inject constructor(
actionFilters: ActionFilters,
val xContentRegistry: NamedXContentRegistry,
private val docLevelMonitorQueries: DocLevelMonitorQueries,
private val settings: Settings,
private val sdkClient: SdkClient
private val settings: Settings
) : HandledTransportAction<ExecuteMonitorRequest, ExecuteMonitorResponse> (
ExecuteMonitorAction.NAME, transportService, actionFilters, ::ExecuteMonitorRequest
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ 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 @@ -63,8 +62,7 @@ class TransportGetAlertsAction @Inject constructor(
actionFilters: ActionFilters,
val settings: Settings,
val xContentRegistry: NamedXContentRegistry,
val namedWriteableRegistry: NamedWriteableRegistry,
val sdkClient: SdkClient
val namedWriteableRegistry: NamedWriteableRegistry
) : HandledTransportAction<ActionRequest, GetAlertsResponse>(
AlertingActions.GET_ALERTS_ACTION_NAME,
transportService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ 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 @@ -51,8 +50,7 @@ class TransportGetDestinationsAction @Inject constructor(
clusterService: ClusterService,
actionFilters: ActionFilters,
val settings: Settings,
val xContentRegistry: NamedXContentRegistry,
val sdkClient: SdkClient
val xContentRegistry: NamedXContentRegistry
) : HandledTransportAction<GetDestinationsRequest, GetDestinationsResponse> (
GetDestinationsAction.NAME, transportService, actionFilters, ::GetDestinationsRequest
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ 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 @@ -60,7 +59,6 @@ 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,7 +40,6 @@ 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 @@ -59,7 +58,6 @@ 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,7 +50,6 @@ 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 @@ -73,7 +72,6 @@ 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,7 +79,6 @@ 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 @@ -102,7 +101,6 @@ 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,7 +40,6 @@ 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 @@ -56,8 +55,7 @@ class TransportSearchAlertingCommentAction @Inject constructor(
val client: Client,
clusterService: ClusterService,
actionFilters: ActionFilters,
val namedWriteableRegistry: NamedWriteableRegistry,
val sdkClient: SdkClient
val namedWriteableRegistry: NamedWriteableRegistry
) : 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,7 +36,6 @@ 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 @@ -56,8 +55,7 @@ class TransportSearchMonitorAction @Inject constructor(
val client: Client,
clusterService: ClusterService,
actionFilters: ActionFilters,
val namedWriteableRegistry: NamedWriteableRegistry,
val sdkClient: SdkClient
val namedWriteableRegistry: NamedWriteableRegistry
) : 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,18 +31,17 @@ 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 manyTriggers = mutableListOf<Trigger>()
val tooManyTriggers = mutableListOf<Trigger>()
for (i in 0..10) {
manyTriggers.add(randomQueryLevelTrigger())
tooManyTriggers.add(randomQueryLevelTrigger())
}

// Should not throw — validation moved to transport layer
val monitorWithManyTriggers = monitor.copy(triggers = manyTriggers)
assertEquals(11, monitorWithManyTriggers.triggers.size)
try {
monitor.copy(triggers = tooManyTriggers)
fail("Monitor with too many triggers should be rejected.")
} catch (e: IllegalArgumentException) {
}
}
}
Loading
Loading