Skip to content

Commit

Permalink
fix(chalice): fixed Elasticsearch-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
tahayk committed Jul 9, 2024
1 parent f41e86b commit d879b8d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions api/chalicelib/core/log_tool_elasticsearch.py
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion api/schemas/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(...)


Expand Down

0 comments on commit d879b8d

Please sign in to comment.