@healthzkit/elasticsearch package provides a HealthAdapter for the official @elastic/elasticsearch client. Each check calls cluster.health() and maps Elasticsearch cluster status to probe status:
Transport or API errors return
fail with the caught error.
Install the adapter package and the peer client:
@elastic/elasticsearch >= 9.
Package entrypoints
@healthzkit/elasticsearch—elasticsearchAdapterand option types.@healthzkit/elasticsearch/elasticsearch—elasticsearchAdapteronly.
Shared options
BaseElasticsearchOptions:
Pass either
config or an existing client (not both).
elasticsearchAdapter
Each check runs client.cluster.health() and records round-trip latency in metadata.latencyMs, plus clusterStatus, clusterName, and numberOfNodes from the health response.
Config
Passconfig as ClientOptions. The adapter lazily imports @elastic/elasticsearch, creates a shared Client, and reuses it across checks. When config is omitted, the default node is http://localhost:9200.
Existing client
Passclient as an existing Client. The adapter reuses that instance across checks.
Check metadata
Successful checks include cluster fields alongside any custommetadata hook output:
yellow cluster yields degraded; a red cluster yields fail while still returning cluster metadata when the API call succeeds.
Wiring into createHealthKit
Treat the factory return value as adapter on a check (same as a hand-written { check() { ... } } object):
schedule on the check if you want cached readiness results instead of calling Elasticsearch on every probe (see Scheduling).