1

Newbie to Rest API and elastic cloud here trying to post my json file in the elasticsearch so I can then index and see it in the kibana. So I read online of the library of elasticsearch and I followed its example basically to the letter. But yet I am getting a connection error when I try and run the thing. Now, the tutorial is refering to on-prem elastic and not cloud so I am guessing the authentication isn't the same for cloud and I should add the user and password somehow to this? Can anyone help me with that?

Do note, when I try to use get I actually get the code 200 so communications should be fine

es = Elasticsearch([{'host': 'https:/cloudhosturl', 'port': 9243}])
    for i,line in enumerate(emails):
        for match in re.finditer(from_pat, line):
            ioc.append(match.group(1))
            es.index(index='senders', doc_type='addresses', id=k, body=json.dumps(match.group(1)))

elasticsearch.exceptions.ConnectionError: ConnectionError(: Failed to establish a new connection: [Errno 11001] getaddrinfo failed) caused by: NewConnectionError(: Failed to establish a new connection: [Errno 11001] getaddrinfo failed)

0

1 Answer 1

2

I'm using the snippet from https://elasticsearch-py.readthedocs.io/en/master/ it works for elastic cloud cluster. It requires pip install elasticsearch

example:

es = Elasticsearch(
['https:/cloudhosturl'],
http_auth=('USERNAME', 'PASSWORD'),
scheme="https", port=443,)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.