Skip to content

Commit

Permalink
[Backport 2.x] Register system index descriptors through SystemIndexP…
Browse files Browse the repository at this point in the history
…lugin.getSystemIndexDescriptors (#1837) (#1840)
  • Loading branch information
cwperks authored Jun 27, 2024
1 parent 6417e0e commit 3d29748
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,6 +31,7 @@ import org.opensearch.observability.settings.PluginSettings
import org.opensearch.plugins.ActionPlugin
import org.opensearch.plugins.ClusterPlugin
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
Expand All @@ -43,7 +45,7 @@ import java.util.function.Supplier
* This class initializes the rest handlers.
*/
@Suppress("TooManyFunctions")
class ObservabilityPlugin : Plugin(), ActionPlugin, ClusterPlugin {
class ObservabilityPlugin : Plugin(), ActionPlugin, ClusterPlugin, SystemIndexPlugin {

companion object {
const val PLUGIN_NAME = "opensearch-observability"
Expand All @@ -59,6 +61,16 @@ class ObservabilityPlugin : Plugin(), ActionPlugin, ClusterPlugin {
return PluginSettings.getAllSettings()
}

/**
* {@inheritDoc}
*/
override fun getSystemIndexDescriptors(settings: Settings): Collection<SystemIndexDescriptor> {
return listOf(
SystemIndexDescriptor(ObservabilityIndex.INDEX_NAME, "Observability Plugin Configuration index"),
SystemIndexDescriptor(ObservabilityIndex.NOTEBOOKS_INDEX_NAME, "Observability Plugin Notebooks index")
)
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import java.util.concurrent.TimeUnit
@Suppress("TooManyFunctions")
internal object ObservabilityIndex : LifecycleListener() {
private val log by logger(ObservabilityIndex::class.java)
private const val INDEX_NAME = ".opensearch-observability"
private const val NOTEBOOKS_INDEX_NAME = ".opensearch-notebooks"
const val INDEX_NAME = ".opensearch-observability"
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"

Expand Down

0 comments on commit 3d29748

Please sign in to comment.