Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions keep/providers/elastic_provider/elastic_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import pydantic
from elasticsearch import Elasticsearch
from elasticsearch.exceptions import UnsupportedProductError

from keep.contextmanager.contextmanager import ContextManager
from keep.exceptions.provider_connection_failed import ProviderConnectionFailed
Expand Down Expand Up @@ -169,6 +170,13 @@ def __initialize_client(self) -> Elasticsearch:
# Check if the connection was successful
try:
es.info()
except UnsupportedProductError:
raise ProviderConnectionFailed(
"Failed to connect to Elasticsearch: the server did not identify itself as "
"Elasticsearch (UnsupportedProductError). This typically happens when connecting "
"to Elasticsearch 7.x with the elasticsearch-py 8.x client. "
"Please upgrade to Elasticsearch 8.x or use elasticsearch-py < 8.0."
)
except Exception as e:
raise ProviderConnectionFailed(
f"Failed to connect to Elasticsearch: {str(e)}"
Expand Down
Loading