Skip to content

Commit 20bd240

Browse files
engechaseirsepsbcd90goyameghjowg-amazon
authored
Backports 2.7 (#1482)
* log error messages and clean up monitor when indexing doc level queries or metadata creation fails (#900) * log errors and clean up monitor when indexing doc level queries or metadata creation fails * refactor delete monitor action to re-use delete methods Signed-off-by: Surya Sashank Nistala <[email protected]> Signed-off-by: Chase Engelbrecht <[email protected]> * optimize doc-level monitor workflow for index patterns (#1097) Signed-off-by: Subhobrata Dey <[email protected]> Signed-off-by: Chase Engelbrecht <[email protected]> * optimize doc-level monitor execution workflow for datastreams (#1302) * optimize doc-level monitor execution for datastreams Signed-off-by: Subhobrata Dey <[email protected]> * add more tests to address comments Signed-off-by: Subhobrata Dey <[email protected]> * add integTest for multiple datastreams inside a single index pattern * add integTest for multiple datastreams inside a single index pattern Signed-off-by: Subhobrata Dey <[email protected]> --------- Signed-off-by: Subhobrata Dey <[email protected]> Signed-off-by: Chase Engelbrecht <[email protected]> * Bulk index findings and sequentially invoke auto-correlations (#1355) * Bulk index findings and sequentially invoke auto-correlations Signed-off-by: Megha Goyal <[email protected]> * Bulk index findings in batches of 10000 and make it configurable Signed-off-by: Megha Goyal <[email protected]> * Addressing review comments Signed-off-by: Megha Goyal <[email protected]> * Add integ tests to test bulk index findings Signed-off-by: Megha Goyal <[email protected]> * Fix ktlint formatting Signed-off-by: Megha Goyal <[email protected]> --------- Signed-off-by: Megha Goyal <[email protected]> Signed-off-by: Chase Engelbrecht <[email protected]> * Add jvm aware setting and max num docs settings for batching docs for percolate queries (#1435) * add jvm aware and max docs settings for batching docs for percolate queries Signed-off-by: Surya Sashank Nistala <[email protected]> * fix stats logging Signed-off-by: Surya Sashank Nistala <[email protected]> * add queryfieldnames field in findings mapping Signed-off-by: Surya Sashank Nistala <[email protected]> --------- Signed-off-by: Surya Sashank Nistala <[email protected]> Signed-off-by: Chase Engelbrecht <[email protected]> * optimize to fetch only fields relevant to doc level queries in doc level monitor instead of entire _source for each doc (#1441) * optimize to fetch only fields relevant to doc level queries in doc level monitor Signed-off-by: Surya Sashank Nistala <[email protected]> * fix test for settings check Signed-off-by: Surya Sashank Nistala <[email protected]> * fix ktlint Signed-off-by: Surya Sashank Nistala <[email protected]> --------- Signed-off-by: Surya Sashank Nistala <[email protected]> Signed-off-by: Chase Engelbrecht <[email protected]> * optimize sequence number calculation and reduce search requests in doc level monitor execution (#1445) * optimize sequence number calculation and reduce search requests by n where n is number of shards being queried in the executino Signed-off-by: Surya Sashank Nistala <[email protected]> * fix tests Signed-off-by: Surya Sashank Nistala <[email protected]> * optimize check indices and execute to query only write index of aliases and datastreams during monitor creation Signed-off-by: Surya Sashank Nistala <[email protected]> * fix test Signed-off-by: Surya Sashank Nistala <[email protected]> * add javadoc Signed-off-by: Surya Sashank Nistala <[email protected]> * add tests to verify seq_no calculation Signed-off-by: Surya Sashank Nistala <[email protected]> --------- Signed-off-by: Surya Sashank Nistala <[email protected]> Signed-off-by: Chase Engelbrecht <[email protected]> * Fix tests Signed-off-by: Chase Engelbrecht <[email protected]> * Fix BWC tests Signed-off-by: Chase Engelbrecht <[email protected]> * clean up doc level queries on dry run (#1430) Signed-off-by: Joanne Wang <[email protected]> Signed-off-by: Chase Engelbrecht <[email protected]> * Fix import Signed-off-by: Chase Engelbrecht <[email protected]> * Fix tests Signed-off-by: Chase Engelbrecht <[email protected]> * Fix BWC version Signed-off-by: Chase Engelbrecht <[email protected]> * Fix another test Signed-off-by: Chase Engelbrecht <[email protected]> * Revert order of operations change Signed-off-by: Chase Engelbrecht <[email protected]> --------- Signed-off-by: Subhobrata Dey <[email protected]> Signed-off-by: Chase Engelbrecht <[email protected]> Signed-off-by: Megha Goyal <[email protected]> Signed-off-by: Surya Sashank Nistala <[email protected]> Signed-off-by: Joanne Wang <[email protected]> Co-authored-by: Surya Sashank Nistala <[email protected]> Co-authored-by: Subhobrata Dey <[email protected]> Co-authored-by: Megha Goyal <[email protected]> Co-authored-by: Joanne Wang <[email protected]>
1 parent af92ba9 commit 20bd240

File tree

16 files changed

+2603
-383
lines changed

16 files changed

+2603
-383
lines changed

alerting/build.gradle

Lines changed: 25 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ apply plugin: 'jacoco'
1616

1717
def usingRemoteCluster = System.properties.containsKey('tests.rest.cluster') || System.properties.containsKey('tests.cluster')
1818
def usingMultiNode = project.properties.containsKey('numNodes')
19+
String bwcVersion = "2.3.0.0"
1920

2021
ext {
2122
projectSubstitutions = [:]
@@ -99,6 +100,9 @@ dependencies {
99100
zipArchive group: 'org.opensearch.plugin', name:'opensearch-notifications-core', version: "${opensearch_build}"
100101
zipArchive group: 'org.opensearch.plugin', name:'notifications', version: "${opensearch_build}"
101102

103+
// Needed for BWC tests
104+
zipArchive group: 'org.opensearch.plugin', name:'alerting', version: "${bwcVersion}-SNAPSHOT"
105+
102106
compileOnly "org.opensearch.plugin:opensearch-scripting-painless-spi:${versions.opensearch}"
103107
api "org.opensearch.plugin:percolator-client:${opensearch_version}"
104108

@@ -247,71 +251,26 @@ task integTestRemote(type: RestIntegTestTask) {
247251
}
248252
integTestRemote.enabled = System.getProperty("tests.rest.cluster") != null
249253

250-
String bwcMinVersion = "1.1.0.0"
251-
String bwcBundleVersion = "1.3.2.0"
252-
Boolean bwcBundleTest = (project.findProperty('customDistributionDownloadType') != null &&
253-
project.properties['customDistributionDownloadType'] == "bundle");
254-
String bwcVersion = bwcBundleTest ? bwcBundleVersion : bwcMinVersion
255-
String bwcCurrentVersion = opensearch_version.replace("-SNAPSHOT", "")
256254
String baseName = "alertingBwcCluster"
257-
String bwcFilePath = "src/test/resources/bwc"
258-
String bwcOpenSearchPlugin = "opensearch-alerting-" + bwcVersion + ".zip"
259-
String bwcRemoteFile = 'https://ci.opensearch.org/ci/dbc/bundle-build/1.1.0/20210930/linux/x64/builds/opensearch/plugins/' + bwcOpenSearchPlugin
260-
261255
2.times {i ->
262256
testClusters {
263257
"${baseName}$i" {
264258
testDistribution = "ARCHIVE"
259+
versions = ["2.3.0-SNAPSHOT", "2.7.1-SNAPSHOT"]
265260
numberOfNodes = 3
266-
if (bwcBundleTest) {
267-
versions = ["1.3.2", bwcCurrentVersion]
268-
nodes.each { node ->
269-
node.extraConfigFile("kirk.pem", file("src/test/resources/kirk.pem"))
270-
node.extraConfigFile("kirk-key.pem", file("src/test/resources/kirk-key.pem"))
271-
node.extraConfigFile("esnode.pem", file("src/test/resources/esnode.pem"))
272-
node.extraConfigFile("esnode-key.pem", file("src/test/resources/esnode-key.pem"))
273-
node.extraConfigFile("root-ca.pem", file("src/test/resources/root-ca.pem"))
274-
node.setting("plugins.security.disabled", "true")
275-
node.setting("plugins.security.ssl.transport.pemcert_filepath", "esnode.pem")
276-
node.setting("plugins.security.ssl.transport.pemkey_filepath", "esnode-key.pem")
277-
node.setting("plugins.security.ssl.transport.pemtrustedcas_filepath", "root-ca.pem")
278-
node.setting("plugins.security.ssl.transport.enforce_hostname_verification", "false")
279-
node.setting("plugins.security.ssl.http.enabled", "true")
280-
node.setting("plugins.security.ssl.http.pemcert_filepath", "esnode.pem")
281-
node.setting("plugins.security.ssl.http.pemkey_filepath", "esnode-key.pem")
282-
node.setting("plugins.security.ssl.http.pemtrustedcas_filepath", "root-ca.pem")
283-
node.setting("plugins.security.allow_unsafe_democertificates", "true")
284-
node.setting("plugins.security.allow_default_init_securityindex", "true")
285-
node.setting("plugins.security.authcz.admin_dn", "CN=kirk,OU=client,O=client,L=test,C=de")
286-
node.setting("plugins.security.audit.type", "internal_elasticsearch")
287-
node.setting("plugins.security.enable_snapshot_restore_privilege", "true")
288-
node.setting("plugins.security.check_snapshot_restore_write_privileges", "true")
289-
node.setting("plugins.security.restapi.roles_enabled", "[\"all_access\", \"security_rest_api_access\"]")
290-
node.setting("plugins.security.system_indices.enabled", "true")
291-
}
292-
} else {
293-
versions = ["1.1.0", opensearch_version]
294-
plugin(provider(new Callable<RegularFile>(){
295-
@Override
296-
RegularFile call() throws Exception {
297-
return new RegularFile() {
298-
@Override
299-
File getAsFile() {
300-
File dir = new File(rootDir.path + "/alerting/" + bwcFilePath + "/alerting/" + bwcVersion)
301-
302-
if (!dir.exists()) {
303-
dir.mkdirs()
304-
}
305-
File f = new File(dir, bwcOpenSearchPlugin)
306-
if (!f.exists()) {
307-
new URL(bwcRemoteFile).withInputStream{ ins -> f.withOutputStream{ it << ins }}
308-
}
309-
return fileTree(bwcFilePath + "/alerting/" + bwcVersion).getSingleFile()
310-
}
261+
plugin(provider(new Callable<RegularFile>(){
262+
@Override
263+
RegularFile call() throws Exception {
264+
return new RegularFile() {
265+
@Override
266+
File getAsFile() {
267+
return configurations.zipArchive.asFileTree.matching {
268+
include '**/alerting*'
269+
}.singleFile
311270
}
312271
}
313-
}))
314-
}
272+
}
273+
}))
315274
setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
316275
setting 'http.content_type.required', 'true'
317276
}
@@ -353,9 +312,7 @@ task prepareBwcTests {
353312
// Create two test clusters with 3 nodes of the old version
354313
2.times {i ->
355314
task "${baseName}#oldVersionClusterTask$i"(type: StandaloneRestIntegTestTask) {
356-
if (!bwcBundleTest){
357-
dependsOn 'prepareBwcTests'
358-
}
315+
dependsOn 'prepareBwcTests'
359316
useCluster testClusters."${baseName}$i"
360317
filter {
361318
includeTestsMatching "org.opensearch.alerting.bwc.*IT"
@@ -374,14 +331,8 @@ task prepareBwcTests {
374331
task "${baseName}#mixedClusterTask"(type: StandaloneRestIntegTestTask) {
375332
useCluster testClusters."${baseName}0"
376333
dependsOn "${baseName}#oldVersionClusterTask0"
377-
if (bwcBundleTest){
378-
doFirst {
379-
testClusters."${baseName}0".nextNodeToNextVersion()
380-
}
381-
} else {
382-
doFirst {
383-
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
384-
}
334+
doFirst {
335+
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
385336
}
386337
filter {
387338
includeTestsMatching "org.opensearch.alerting.bwc.*IT"
@@ -399,14 +350,8 @@ task "${baseName}#mixedClusterTask"(type: StandaloneRestIntegTestTask) {
399350
task "${baseName}#twoThirdsUpgradedClusterTask"(type: StandaloneRestIntegTestTask) {
400351
dependsOn "${baseName}#mixedClusterTask"
401352
useCluster testClusters."${baseName}0"
402-
if (bwcBundleTest){
403-
doFirst {
404-
testClusters."${baseName}0".nextNodeToNextVersion()
405-
}
406-
} else {
407-
doFirst {
408-
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
409-
}
353+
doFirst {
354+
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
410355
}
411356
filter {
412357
includeTestsMatching "org.opensearch.alerting.bwc.*IT"
@@ -424,14 +369,8 @@ task "${baseName}#twoThirdsUpgradedClusterTask"(type: StandaloneRestIntegTestTas
424369
task "${baseName}#rollingUpgradeClusterTask"(type: StandaloneRestIntegTestTask) {
425370
dependsOn "${baseName}#twoThirdsUpgradedClusterTask"
426371
useCluster testClusters."${baseName}0"
427-
if (bwcBundleTest){
428-
doFirst {
429-
testClusters."${baseName}0".nextNodeToNextVersion()
430-
}
431-
} else {
432-
doFirst {
433-
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
434-
}
372+
doFirst {
373+
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
435374
}
436375
filter {
437376
includeTestsMatching "org.opensearch.alerting.bwc.*IT"
@@ -449,14 +388,8 @@ task "${baseName}#rollingUpgradeClusterTask"(type: StandaloneRestIntegTestTask)
449388
task "${baseName}#fullRestartClusterTask"(type: StandaloneRestIntegTestTask) {
450389
dependsOn "${baseName}#oldVersionClusterTask1"
451390
useCluster testClusters."${baseName}1"
452-
if (bwcBundleTest){
453-
doFirst {
454-
testClusters."${baseName}1".goToNextVersion()
455-
}
456-
} else {
457-
doFirst {
458-
testClusters."${baseName}1".upgradeAllNodesAndPluginsToNextVersion(plugins)
459-
}
391+
doFirst {
392+
testClusters."${baseName}1".upgradeAllNodesAndPluginsToNextVersion(plugins)
460393
}
461394
filter {
462395
includeTestsMatching "org.opensearch.alerting.bwc.*IT"

alerting/src/main/kotlin/org/opensearch/alerting/AlertingPlugin.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import org.opensearch.alerting.resthandler.RestSearchEmailGroupAction
3939
import org.opensearch.alerting.resthandler.RestSearchMonitorAction
4040
import org.opensearch.alerting.script.TriggerScript
4141
import org.opensearch.alerting.settings.AlertingSettings
42+
import org.opensearch.alerting.settings.AlertingSettings.Companion.DOC_LEVEL_MONITOR_SHARD_FETCH_SIZE
4243
import org.opensearch.alerting.settings.DestinationSettings
4344
import org.opensearch.alerting.settings.LegacyOpenDistroAlertingSettings
4445
import org.opensearch.alerting.settings.LegacyOpenDistroDestinationSettings
@@ -83,6 +84,7 @@ import org.opensearch.core.xcontent.XContentParser
8384
import org.opensearch.env.Environment
8485
import org.opensearch.env.NodeEnvironment
8586
import org.opensearch.index.IndexModule
87+
import org.opensearch.monitor.jvm.JvmStats
8688
import org.opensearch.painless.spi.PainlessExtension
8789
import org.opensearch.painless.spi.Whitelist
8890
import org.opensearch.painless.spi.WhitelistLoader
@@ -237,6 +239,7 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, R
237239
.registerTriggerService(TriggerService(scriptService))
238240
.registerAlertService(AlertService(client, xContentRegistry, alertIndices))
239241
.registerDocLevelMonitorQueries(DocLevelMonitorQueries(client, clusterService))
242+
.registerJvmStats(JvmStats.jvmStats())
240243
.registerConsumers()
241244
.registerDestinationSettings()
242245
scheduledJobIndices = ScheduledJobIndices(client.admin(), clusterService)
@@ -284,6 +287,9 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, R
284287
AlertingSettings.ALERT_HISTORY_MAX_DOCS,
285288
AlertingSettings.ALERT_HISTORY_RETENTION_PERIOD,
286289
AlertingSettings.ALERTING_MAX_MONITORS,
290+
AlertingSettings.PERCOLATE_QUERY_DOCS_SIZE_MEMORY_PERCENTAGE_LIMIT,
291+
DOC_LEVEL_MONITOR_SHARD_FETCH_SIZE,
292+
AlertingSettings.PERCOLATE_QUERY_MAX_NUM_DOCS_IN_MEMORY,
287293
AlertingSettings.REQUEST_TIMEOUT,
288294
AlertingSettings.MAX_ACTION_THROTTLE_VALUE,
289295
AlertingSettings.FILTER_BY_BACKEND_ROLES,
@@ -304,6 +310,7 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, R
304310
LegacyOpenDistroAlertingSettings.REQUEST_TIMEOUT,
305311
LegacyOpenDistroAlertingSettings.MAX_ACTION_THROTTLE_VALUE,
306312
LegacyOpenDistroAlertingSettings.FILTER_BY_BACKEND_ROLES,
313+
AlertingSettings.DOC_LEVEL_MONITOR_FETCH_ONLY_QUERY_FIELDS_ENABLED,
307314
DestinationSettings.EMAIL_USERNAME,
308315
DestinationSettings.EMAIL_PASSWORD,
309316
DestinationSettings.ALLOW_LIST,
@@ -316,7 +323,8 @@ internal class AlertingPlugin : PainlessExtension, ActionPlugin, ScriptPlugin, R
316323
AlertingSettings.FINDING_HISTORY_MAX_DOCS,
317324
AlertingSettings.FINDING_HISTORY_INDEX_MAX_AGE,
318325
AlertingSettings.FINDING_HISTORY_ROLLOVER_PERIOD,
319-
AlertingSettings.FINDING_HISTORY_RETENTION_PERIOD
326+
AlertingSettings.FINDING_HISTORY_RETENTION_PERIOD,
327+
AlertingSettings.FINDINGS_INDEXING_BATCH_SIZE
320328
)
321329
}
322330

0 commit comments

Comments
 (0)