Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for ElasticSearch 7.x Support #2226

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
22 changes: 11 additions & 11 deletions elastalert/create_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,24 +243,24 @@ def main():
except NotFoundError:
# Why does this ever occur?? It shouldn't. But it does.
pass
es_index.create(index_name)
es_index.create(index_name, params={"include_type_name": "true"})

# To avoid a race condition. TODO: replace this with a real check
time.sleep(2)

if(elasticversion > 5):
es.indices.put_mapping(index=index, doc_type='elastalert', body=es_mapping)
es.indices.put_mapping(index=index + '_status', doc_type='elastalert_status', body=ess_mapping)
es.indices.put_mapping(index=index + '_silence', doc_type='silence', body=silence_mapping)
es.indices.put_mapping(index=index + '_error', doc_type='elastalert_error', body=error_mapping)
es.indices.put_mapping(index=index + '_past', doc_type='past_elastalert', body=past_mapping)
es.indices.put_mapping(index=index, doc_type='elastalert', body=es_mapping, params={"include_type_name": "true"})
es.indices.put_mapping(index=index + '_status', doc_type='elastalert_status', body=ess_mapping, params={"include_type_name": "true"})
es.indices.put_mapping(index=index + '_silence', doc_type='silence', body=silence_mapping, params={"include_type_name": "true"})
es.indices.put_mapping(index=index + '_error', doc_type='elastalert_error', body=error_mapping, params={"include_type_name": "true"})
es.indices.put_mapping(index=index + '_past', doc_type='past_elastalert', body=past_mapping, params={"include_type_name": "true"})
print('New index %s created' % index)
else:
es.indices.put_mapping(index=index, doc_type='elastalert', body=es_mapping)
es.indices.put_mapping(index=index, doc_type='elastalert_status', body=ess_mapping)
es.indices.put_mapping(index=index, doc_type='silence', body=silence_mapping)
es.indices.put_mapping(index=index, doc_type='elastalert_error', body=error_mapping)
es.indices.put_mapping(index=index, doc_type='past_elastalert', body=past_mapping)
es.indices.put_mapping(index=index, doc_type='elastalert', body=es_mapping, params={"include_type_name": "true"})
es.indices.put_mapping(index=index, doc_type='elastalert_status', body=ess_mapping, params={"include_type_name": "true"})
es.indices.put_mapping(index=index, doc_type='silence', body=silence_mapping, params={"include_type_name": "true"})
es.indices.put_mapping(index=index, doc_type='elastalert_error', body=error_mapping, params={"include_type_name": "true"})
es.indices.put_mapping(index=index, doc_type='past_elastalert', body=past_mapping, params={"include_type_name": "true"})
print('New index %s created' % index)

if old_index:
Expand Down