'python elasticsearch-dsl, connection with SSL certificate example?
i've got some scripts i've been using for years that pull data from an elasticsearch cluster. I recently added tls/ssl encryption to the elasticsearch cluster. This broke all my python scripts. I cant seem to find any good examples of how to use the certificates to create a connection. here is my code that has worked until i added the tls/ssl.
yes i've read the documentation.. yes i've googled.. and looked on stack exchange and the elastic descussion boards.
def queryES_timeframe(self, timeframe):
print("Getting:", timeframe, " Data, please wait")
# builds connection string from yaml data
connectionString="https://"+ str(self.es_host) + ":" + str(self.es_port)
client = connections.create_connection(hosts=[connectionString], timeout=90,http_auth=(self.elk_user,self.elk_password))
# performs search query
s = Search(using=client, index=self.es_index).filter('range', **{'@timestamp': {'gte': timeframe}})
results = s.execute()
total = s.execute().hits.total
links = s.execute().hits.hits
s_dict = results.to_dict()
print("Pulling Data Please wait")
startTime = datetime.now()
count = 0
for hit in tqdm(s.scan()):
count += 1
self.DataList.append(hit.to_dict())
# print (self.DataList)
print("Count:", count)
print("Time Taken:", datetime.now() - startTime)
self.timeToQuery = datetime.now() - startTime
i just need to know how to point it at my cert.. and which certs to use.. ca? client? both? what format do they need to be in?
thank you
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
