diff --git a/api/chalicelib/core/log_tool_elasticsearch.py b/api/chalicelib/core/log_tool_elasticsearch.py index 6afc120b11..496d3eeea3 100644 --- a/api/chalicelib/core/log_tool_elasticsearch.py +++ b/api/chalicelib/core/log_tool_elasticsearch.py @@ -1,10 +1,11 @@ -from elasticsearch import Elasticsearch -from chalicelib.core import log_tools import logging +from elasticsearch import Elasticsearch + +from chalicelib.core import log_tools from schemas import schemas -logging.getLogger('elasticsearch').level = logging.ERROR +logger = logging.getLogger(__name__) IN_TY = "elasticsearch" @@ -63,9 +64,9 @@ def __get_es_client(host, port, api_key_id, api_key, use_ssl=False, timeout=15): try: args = { "hosts": [{"host": host, "port": port, "scheme": scheme}], - "verify_certs": False, + "verify_certs": use_ssl, "request_timeout": timeout, - "api_key": (api_key_id, api_key) + "api_key": api_key } es = Elasticsearch( **args @@ -76,8 +77,8 @@ def __get_es_client(host, port, api_key_id, api_key, use_ssl=False, timeout=15): if not r: return None except Exception as err: - print("================exception connecting to ES host:") - print(err) + logger.error("================exception connecting to ES host:") + logger.exception(err) return None return es diff --git a/api/schemas/schemas.py b/api/schemas/schemas.py index df34a6dc34..f074f10bee 100644 --- a/api/schemas/schemas.py +++ b/api/schemas/schemas.py @@ -323,7 +323,7 @@ class IntegrationCloudwatchSchema(IntegrationCloudwatchBasicSchema): class IntegrationElasticsearchTestSchema(IntegrationBase): host: str = Field(...) port: int = Field(...) - api_key_id: str = Field(...) + api_key_id: Optional[str] = Field(default=None) api_key: str = Field(...)