how to connect to elastic search which address is given in the form of DNS using python

Viewed 133

before if I had to connect to elastic search I was able to connect like this that time the es_host used to be like an IP ex:- http://34.102.80.90 and port 9200

Elasticsearch(es_host+':'+es_port,http_auth=(es_username,es_password),verify_certs=False,ssl_context=ssl_context)

now the address for es is given in the form of address like http://prod-es-cluster.ai and was told that it can only be accessible if you connect through a VPN now after connecting through VPN if I send a curl request like this

curl -X GET http://prod-es-cluster.ai/_cat/indices -u elastic:password

I was getting the response

but when I'm trying to make a connection in python client

es =  Elasticsearch('http://prod-es-cluster.ai',http_auth=(es_username,es_password),verify_certs=False,ssl_context=ssl_context)
if not es.ping():
        raise ValueError("Connection failed")

I'm getting connection failed

I also tried putting port still same error

es =  Elasticsearch('http://prod-es-cluster.ai:9200',http_auth=(es_username,es_password),verify_certs=False,ssl_context=ssl_context)
    if not es.ping():
            raise ValueError("Connection failed")

also tried connecting like this but still the same error

es = Elasticsearch(['http://elastic:password@prod-es-cluster.ai:9200'])

es = Elasticsearch(['http://elastic:password@prod-es-cluster.ai'])

es is deployed in the GCP Kubernetes cluster.

0 Answers
Related