From 5742ed627dcb5b4550e3577a872c131888170bbb Mon Sep 17 00:00:00 2001 From: Subhobrata Dey Date: Tue, 13 Feb 2024 03:23:40 +0000 Subject: [PATCH] update system indices with fixed no. of primary shards & auto expand replicas Signed-off-by: Subhobrata Dey --- .../org/opensearch/alerting/alerts/AlertIndices.kt | 9 ++++++++- .../opensearch/alerting/util/DocLevelMonitorQueries.kt | 6 +++++- .../opensearch/alerting/resthandler/MonitorRestApiIT.kt | 6 +++--- .../org/opensearch/alerting/core/ScheduledJobIndices.kt | 9 ++++++++- core/src/main/resources/settings/doc-level-queries.json | 6 ++++-- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/alerts/AlertIndices.kt b/alerting/src/main/kotlin/org/opensearch/alerting/alerts/AlertIndices.kt index c9b730f1f..91f8293f7 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/alerts/AlertIndices.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/alerts/AlertIndices.kt @@ -359,7 +359,14 @@ class AlertIndices( logger.debug("index: [$index] schema mappings: [$schemaMapping]") val request = CreateIndexRequest(index) .mapping(schemaMapping) - .settings(Settings.builder().put("index.hidden", true).build()) + .settings( + Settings + .builder() + .put("index.hidden", true) + .put("number_of_shards", "1") + .put("index.auto_expand_replicas", "0-all") + .build() + ) if (alias != null) request.alias(Alias(alias)) return try { diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/util/DocLevelMonitorQueries.kt b/alerting/src/main/kotlin/org/opensearch/alerting/util/DocLevelMonitorQueries.kt index 42237853f..add03e6d8 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/util/DocLevelMonitorQueries.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/util/DocLevelMonitorQueries.kt @@ -117,7 +117,11 @@ class DocLevelMonitorQueries(private val client: Client, private val clusterServ .mapping(docLevelQueriesMappings()) .alias(Alias(alias)) .settings( - Settings.builder().put("index.hidden", true) + Settings + .builder() + .put("index.hidden", true) + .put("number_of_shards", "1") + .put("index.auto_expand_replicas", "0-all") .build() ) return try { diff --git a/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/MonitorRestApiIT.kt b/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/MonitorRestApiIT.kt index 25e8d319d..d9002c9bd 100644 --- a/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/MonitorRestApiIT.kt +++ b/alerting/src/test/kotlin/org/opensearch/alerting/resthandler/MonitorRestApiIT.kt @@ -979,7 +979,7 @@ class MonitorRestApiIT : AlertingRestTestCase() { if (isMultiNode) { assertEquals("Scheduled job index is not green", "green", alertingStats["scheduled_job_index_status"]) } else { - assertEquals("Scheduled job index is not yellow", "yellow", alertingStats["scheduled_job_index_status"]) + assertEquals("Scheduled job index is not green", "green", alertingStats["scheduled_job_index_status"]) } assertEquals("Nodes are not on schedule", numberOfNodes, alertingStats["nodes_on_schedule"]) @@ -1043,7 +1043,7 @@ class MonitorRestApiIT : AlertingRestTestCase() { if (isMultiNode) { assertEquals("Scheduled job index is not green", "green", responseMap["scheduled_job_index_status"]) } else { - assertEquals("Scheduled job index is not yellow", "yellow", responseMap["scheduled_job_index_status"]) + assertEquals("Scheduled job index is not green", "green", responseMap["scheduled_job_index_status"]) } assertEquals("Nodes are not on schedule", numberOfNodes, responseMap["nodes_on_schedule"]) @@ -1078,7 +1078,7 @@ class MonitorRestApiIT : AlertingRestTestCase() { if (isMultiNode) { assertEquals("Scheduled job index is not green", "green", responseMap["scheduled_job_index_status"]) } else { - assertEquals("Scheduled job index is not yellow", "yellow", responseMap["scheduled_job_index_status"]) + assertEquals("Scheduled job index is not green", "green", responseMap["scheduled_job_index_status"]) } assertEquals("Nodes not on schedule", numberOfNodes, responseMap["nodes_on_schedule"]) diff --git a/core/src/main/kotlin/org/opensearch/alerting/core/ScheduledJobIndices.kt b/core/src/main/kotlin/org/opensearch/alerting/core/ScheduledJobIndices.kt index a71a7e64f..cb321421e 100644 --- a/core/src/main/kotlin/org/opensearch/alerting/core/ScheduledJobIndices.kt +++ b/core/src/main/kotlin/org/opensearch/alerting/core/ScheduledJobIndices.kt @@ -38,7 +38,14 @@ class ScheduledJobIndices(private val client: AdminClient, private val clusterSe if (!scheduledJobIndexExists()) { var indexRequest = CreateIndexRequest(ScheduledJob.SCHEDULED_JOBS_INDEX) .mapping(scheduledJobMappings()) - .settings(Settings.builder().put("index.hidden", true).build()) + .settings( + Settings + .builder() + .put("index.hidden", true) + .put("number_of_shards", "1") + .put("index.auto_expand_replicas", "0-all") + .build() + ) client.indices().create(indexRequest, actionListener) } } diff --git a/core/src/main/resources/settings/doc-level-queries.json b/core/src/main/resources/settings/doc-level-queries.json index c5cbfa445..f5fd24277 100644 --- a/core/src/main/resources/settings/doc-level-queries.json +++ b/core/src/main/resources/settings/doc-level-queries.json @@ -5,6 +5,8 @@ "limit": 10000 } }, - "hidden": true - } + "hidden": true, + "auto_expand_replicas": "0-all" + }, + "number_of_shards": 1 } \ No newline at end of file