Integration with elasticsearch v5
Hi
I know that the new version v5 of elasticsearch has just being released, but do you know when it will be available the integration of elastalert with the new version? At the moment I am getting:
INFO:elastalert:Starting up WARNING:elasticsearch:POST http://elasticsearch:9200/elastalert_status/elastalert/_search?size=1000 [status:400 request:0.013s] WARNING:elasticsearch:POST http://elasticsearch:9200/elastalert_status/elastalert_status/_search?_source_include=endtime%2Crule_name&size=1 [status:400 request:0.002s] ERROR:root:Error querying for last run: TransportError(400, {u'line': 1, u'root_cause': [{u'reason': u'Unknown key for a START_OBJECT in [filter].', u'type': u'parsing_exception', u'line': 1, u'col': 12}], u'type': u'parsing_exception', u'reason': u'Unknown key for a START_OBJECT in [filter].', u'col': 12}) WARNING:elasticsearch:POST http://elasticsearch:9200/elastalert_status/elastalert_error?op_type=create [status:400 request:0.003s] ERROR:root:Error writing alert info to elasticsearch: TransportError(400, {u'root_cause': [{u'reason': u'Validation Failed: 1: an id must be provided if version type or value are set;', u'type': u'action_request_validation_exception'}], u'type': u'action_request_validation_exception', u'reason': u'Validation Failed: 1: an id must be provided if version type or value are set;'}) Traceback (most recent call last): File "/opt/elastalert/elastalert/elastalert.py", line 1033, in writeback doc_type=doc_type, body=body) File "/usr/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 68, in _wrapped return func(*args, params=params, **kwargs) File "/usr/lib/python2.7/site-packages/elasticsearch/client/init.py", line 227, in create return self.index(index, doc_type, body, id=id, params=params, op_type='create') File "/usr/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 68, in _wrapped return func(args, params=params, **kwargs) File "/usr/lib/python2.7/site-packages/elasticsearch/client/init.py", line 257, in index _make_path(index, doc_type, id), params=params, body=body) File "/usr/lib/python2.7/site-packages/elasticsearch/transport.py", line 301, in perform_request status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout) File "/usr/lib/python2.7/site-packages/elasticsearch/connection/http_requests.py", line 72, in perform_request self._raise_error(response.status_code, raw_data) File "/usr/lib/python2.7/site-packages/elasticsearch/connection/base.py", line 102, in _raise_error raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info) RequestError: TransportError(400, {u'root_cause': [{u'reason': u'Validation Failed: 1: an id must be provided if version type or value are set;', u'type': u'action_request_validation_exception'}], u'type': u'action_request_validation_exception', u'reason': u'Validation Failed: 1: an id must be provided if version type or value are set;'}) WARNING:elasticsearch:GET http://elasticsearch:9200/payment-/_search?_source_include=eventtime%2C%2A%2CuserId&ignore_unavailable=true&size=10000 [status:400 request:0.003s] ERROR:root:Error running query: TransportError(400, {u'line': 1, u'root_cause': [{u'reason': u'no [query] registered for [filtered]', u'type': u'parsing_exception', u'line': 1, u'col': 67}], u'type': u'parsing_exception', u'reason': u'no [query] registered for [filtered]', u'col': 67}) WARNING:elasticsearch:POST http://elasticsearch:9200/elastalert_status/elastalert_error?op_type=create [status:400 request:0.003s] ERROR:root:Error writing alert info to elasticsearch: TransportError(400, {u'root_cause': [{u'reason': u'Validation Failed: 1: an id must be provided if version type or value are set;', u'type': u'action_request_validation_exception'}], u'type': u'action_request_validation_exception', u'reason': u'Validation Failed: 1: an id must be provided if version type or value are set;'}) Traceback (most recent call last): File "/opt/elastalert/elastalert/elastalert.py", line 1033, in writeback doc_type=doc_type, body=body) File "/usr/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 68, in _wrapped return func(*args, params=params, **kwargs) File "/usr/lib/python2.7/site-packages/elasticsearch/client/init.py", line 227, in create return self.index(index, doc_type, body, id=id, params=params, op_type='create') File "/usr/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 68, in _wrapped return func(*args, params=params, **kwargs) File "/usr/lib/python2.7/site-packages/elasticsearch/client/init.py", line 257, in index _make_path(index, doc_type, id), params=params, body=body) File "/usr/lib/python2.7/site-packages/elasticsearch/transport.py", line 301, in perform_request status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout) File "/usr/lib/python2.7/site-packages/elasticsearch/connection/http_requests.py", line 72, in perform_request self._raise_error(response.status_code, raw_data) File "/usr/lib/python2.7/site-packages/elasticsearch/connection/base.py", line 102, in _raise_error raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info) RequestError: TransportError(400, {u'root_cause': [{u'reason': u'Validation Failed: 1: an id must be provided if version type or value are set;', u'type': u'action_request_validation_exception'}], u'type': u'action_request_validation_exception', u'reason': u'Validation Failed: 1: an id must be provided if version type or value are set;'}) INFO:elastalert:Ran User1111MakePayment from 2016-11-02 08:20 UTC to 2016-11-02 13:20 UTC: 0 query hits, 0 matches, 0 alerts sent
Thanks for this great tool!!!!
ES 5 has been around for a while already, its the GA version that just came out, any ETA on the support would be lovely :+1:
+1
+1
+1
On Sat, Nov 5, 2016 at 5:14 AM -0700, "lrolsen" <[email protected]mailto:[email protected]> wrote:
+1
You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/Yelp/elastalert/issues/790#issuecomment-258607858, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AH7j4V-D_DPsJ-KmIqww-sOMgZ5FaPG-ks5q7HMggaJpZM4KnOvN.
@watollop say me to put +1 here
+1
+1
+1
+1 Duplicate of #510
+1
+1
Is it known what is broken and how can we help ?
IRC pointed me to https://github.com/Yelp/elastalert/blob/master/elastalert/elastalert.py#L159
+1
Is it known what is broken and how can we help ?
as i known, it is because "filter" is not available any more in ES 5.0.
There are many "filter" query in EA which will get the 400 HTTP response for the incorrect query clause.
+1
+1
It looks like all needed is to rewrite this query: https://github.com/Yelp/elastalert/blob/master/elastalert/elastalert.py#L159 (thanks @bkeifer )
Documentation says that change should be simple: https://www.elastic.co/guide/en/elasticsearch/reference/5.0/query-dsl-filtered-query.html
I'll try to find some time, my python is a bit rusty :)
My reading of that doc suggests that the change should be:
diff --git a/elastalert/elastalert.py b/elastalert/elastalert.py
index 2cbd553..a13e739 100644
--- a/elastalert/elastalert.py
+++ b/elastalert/elastalert.py
@@ -156,7 +156,7 @@ class ElastAlerter():
if starttime and endtime:
es_filters['filter']['bool']['must'].insert(0, {'range': {timestamp_field: {'gt': starttime,
'lte': endtime}}})
- query = {'query': {'filtered': es_filters}}
+ query = {'query': {'bool': es_filters}}
if sort:
query['sort'] = [{timestamp_field: {'order': 'desc' if desc else 'asc'}}]
return query
I'll see if I can make it work in our ES5 environment
@timwsuqld: plus if statement to detect ES version