Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 638 Bytes

File metadata and controls

31 lines (24 loc) · 638 Bytes
endpoint ping
lang python
es_version 9.3
client elasticsearch==9.3.0

Elasticsearch 9.3 ping endpoint (Python example)

Use client.ping() to check whether the Elasticsearch server is reachable. Returns True if the server responds, False otherwise.

if client.ping():
    print("Elasticsearch is available")
else:
    print("Elasticsearch is not reachable")

Startup health check

Use ping at application startup to fail fast if Elasticsearch is unavailable:

import sys

if not client.ping():
    print("Cannot connect to Elasticsearch — exiting", file=sys.stderr)
    sys.exit(1)