Back to Kibana

@kbn/core-elasticsearch-server-internal

src/core/packages/elasticsearch/server-internal/README.md

9.4.01.5 KB
Original Source

@kbn/core-elasticsearch-server-internal

This package contains the internal types and implementation for Core's server-side elasticsearch service.

ElasticsearchService

The ElasticsearchService is one of the Core services (instantiated in @src/core/packages/root/server-internal/src/server.ts) that provides connectivity to Elasticsearch for Kibana.

Purpose

It manages the lifecycle of Elasticsearch clients, ensures the connection is healthy and compatible, and exposes APIs for plugins to interact with Elasticsearch.

Key Features

  • Client Management: Creates and manages ClusterClient instances (e.g., data client), providing both internal-user and request-scoped access.
  • Connection Health: Periodically polls Elasticsearch nodes to verify version compatibility (esNodesCompatibility$) and calculates the overall service status (status$).
  • Preboot & Setup:
    • Loads configuration (elasticsearch.hosts, username/password or serviceAccountToken, etc.).
    • Initializes the AgentManager for HTTP agent reuse.
    • Registers analytics context providers.
  • Startup Checks:
    • Validates the connection to Elasticsearch.
    • Verifies that inline scripting is enabled on the cluster.
    • Fetches and exposes cluster capabilities.
  • Cross-Project Search (CPS) Handling: Configures the CpsRequestHandler based on the cps.cpsEnabled flag. See @kbn/core-elasticsearch-client-server-internal — CPS Request Handler for full details.