From 72079340add65cef770d9eb17264882053245b1e Mon Sep 17 00:00:00 2001 From: Craig Perkins Date: Fri, 21 Jun 2024 16:28:03 -0400 Subject: [PATCH] Register system index descriptors through SystemIndexPlugin.getSystemIndexDescriptors Signed-off-by: Craig Perkins --- .../opensearch/observability/ObservabilityPlugin.kt | 13 ++++++++++++- .../observability/index/ObservabilityIndex.kt | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/org/opensearch/observability/ObservabilityPlugin.kt b/src/main/kotlin/org/opensearch/observability/ObservabilityPlugin.kt index 1c27612f1..e34a516cc 100644 --- a/src/main/kotlin/org/opensearch/observability/ObservabilityPlugin.kt +++ b/src/main/kotlin/org/opensearch/observability/ObservabilityPlugin.kt @@ -19,6 +19,7 @@ import org.opensearch.core.common.io.stream.NamedWriteableRegistry import org.opensearch.core.xcontent.NamedXContentRegistry import org.opensearch.env.Environment import org.opensearch.env.NodeEnvironment +import org.opensearch.indices.SystemIndexDescriptor import org.opensearch.observability.action.CreateObservabilityObjectAction import org.opensearch.observability.action.DeleteObservabilityObjectAction import org.opensearch.observability.action.GetObservabilityObjectAction @@ -29,6 +30,7 @@ import org.opensearch.observability.resthandler.ObservabilityStatsRestHandler import org.opensearch.observability.settings.PluginSettings import org.opensearch.plugins.ActionPlugin import org.opensearch.plugins.Plugin +import org.opensearch.plugins.SystemIndexPlugin import org.opensearch.repositories.RepositoriesService import org.opensearch.rest.RestController import org.opensearch.rest.RestHandler @@ -41,7 +43,7 @@ import java.util.function.Supplier * Entry point of the OpenSearch Observability plugin. * This class initializes the rest handlers. */ -class ObservabilityPlugin : Plugin(), ActionPlugin { +class ObservabilityPlugin : Plugin(), ActionPlugin, SystemIndexPlugin { companion object { const val PLUGIN_NAME = "opensearch-observability" @@ -57,6 +59,15 @@ class ObservabilityPlugin : Plugin(), ActionPlugin { return PluginSettings.getAllSettings() } + /** + * {@inheritDoc} + */ + override fun getSystemIndexDescriptors(settings: Settings): Collection { + return listOf( + SystemIndexDescriptor(ObservabilityIndex.INDEX_NAME, "Observability Plugin system index pattern") + ) + } + /** * {@inheritDoc} */ diff --git a/src/main/kotlin/org/opensearch/observability/index/ObservabilityIndex.kt b/src/main/kotlin/org/opensearch/observability/index/ObservabilityIndex.kt index b0c45997c..bcf5950cb 100644 --- a/src/main/kotlin/org/opensearch/observability/index/ObservabilityIndex.kt +++ b/src/main/kotlin/org/opensearch/observability/index/ObservabilityIndex.kt @@ -50,7 +50,7 @@ import java.util.concurrent.TimeUnit @Suppress("TooManyFunctions") internal object ObservabilityIndex { private val log by logger(ObservabilityIndex::class.java) - private const val INDEX_NAME = ".opensearch-observability" + const val INDEX_NAME = ".opensearch-observability" private const val NOTEBOOKS_INDEX_NAME = ".opensearch-notebooks" private const val OBSERVABILITY_MAPPING_FILE_NAME = "observability-mapping.yml" private const val OBSERVABILITY_SETTINGS_FILE_NAME = "observability-settings.yml"