diff --git a/api/chalicelib/core/log_tool_elasticsearch.py b/api/chalicelib/core/log_tool_elasticsearch.py index 680c28e23..d8a7de2fd 100644 --- a/api/chalicelib/core/log_tool_elasticsearch.py +++ b/api/chalicelib/core/log_tool_elasticsearch.py @@ -59,20 +59,21 @@ def add_edit(tenant_id, project_id, data): def __get_es_client(host, port, api_key_id, api_key, use_ssl=False, timeout=15): + schema = "http" if host.startswith("http") else "https" host = host.replace("http://", "").replace("https://", "") try: args = { - "hosts": [{"host": host, "port": port}], - "use_ssl": use_ssl, + "hosts": [{"host": host, "port": port, "schema": schema}], "verify_certs": False, - "ca_certs": False, + # "ca_certs": False, # "connection_class": RequestsHttpConnection, - "timeout": timeout + "request_timeout": timeout, + "api_key": (api_key_id, api_key) } - if api_key_id is not None and len(api_key_id) > 0: - # args["http_auth"] = (username, password) - token = "ApiKey " + base64.b64encode(f"{api_key_id}:{api_key}".encode("utf-8")).decode("utf-8") - args["headers"] = {"Authorization": token} + # if api_key_id is not None and len(api_key_id) > 0: + # # args["http_auth"] = (username, password) + # token = "ApiKey " + base64.b64encode(f"{api_key_id}:{api_key}".encode("utf-8")).decode("utf-8") + # args["headers"] = {"Authorization": token} es = Elasticsearch( **args )