Reputation: 461
I want to get the health of an elasticsearch cluster similar to the command
curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'
but using python. I did the following
from elasticsearch.client import ClusterClient
esc = ClusterClient([{'host': 'localhost', 'port': 9200}])
esc.health();
but all I get is an
AttributeError: 'list' object has no attribute 'transport'
I played around with some parameters for health() such us index and level but I mess around the syntax. Has someone a working example?
Regards, Tobi
Upvotes: 5
Views: 10357
Reputation: 1586
from elasticsearch import Elasticsearch
es = Elasticsearch([{'host': 'localhost', 'port': 9200}])
print(es.cat.health())
Upvotes: 3
Reputation: 383
You can't use the Cluster API directly, try this:
from elasticsearch import Elasticsearch
es = Elasticsearch()
print(es.cluster.health())
Upvotes: 11