Skip to content

Commit

Permalink
Fixing get_hits_count for es 7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffAshton committed Jul 7, 2021
1 parent 3df7643 commit b9ff8b8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion elastalert/elastalert.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,21 @@ def get_hits_count(self, rule, starttime, endtime, index):
five=rule['five']
)

es_client = self.thread_data.current_es
try:
res = self.thread_data.current_es.count(index=index, doc_type=rule['doc_type'], body=query, ignore_unavailable=True)
if es_client.is_atleastsixsix():
res = es_client.count(
index=index,
body=query,
ignore_unavailable=True
)
else:
res = es_client.count(
index=index,
doc_type=rule['doc_type'],
body=query,
ignore_unavailable=True
)
except ElasticsearchException as e:
# Elasticsearch sometimes gives us GIGANTIC error messages
# (so big that they will fill the entire terminal buffer)
Expand Down

0 comments on commit b9ff8b8

Please sign in to comment.