Duplicated alerts
Hello everybody,
I have this setup:
- 2 instance of elastalert (in docker container)
- graylog
- elastalert version : 0.1.16
- elasticsearch version : 2.4.2 (1 cluster of two nodes)
I have the following aggregation rule (this is exactly the same rule on the two instance of elastalert):
name: "##Admin_Added"
index: windows_*
query_key: MemberName
type: any
filter:
- query:
query_string:
query: 'EventID: 4728'
aggregation:
schedule: '0 5,10,15 * * mon,tue,wed,thu,fri *'
aggregation_key: MemberName
Alert works well (and I'm sure that aggregation key is well uniq) but two alerts are triggered for the SAME events. These two alerts have been sent at 15:00PM.
-> I made an alert for elastalert error, the following error has triggered at the same time as the duplicated alerts:
@timestamp: 2017-07-12T15:00:13.410295Z _id: AV03UJHkAy_HQqQOgkUo _index: elastalert_status _type: elastalert_error data: { "id": "AV03DaVsAy_HQqQOgkF1" } message: Error fetching aggregated matches: TransportError(404, u'{"found":false,"_index":"elastalert_status","_type":"elastalert","_id":"AV03DaYQAy_HQqQOgkF2","_version":3,"_shards":{"total":2,"successful":2,"failed":0}}') num_hits: 2 num_matches: 2 traceback: [ "Traceback (most recent call last):", " File \"/opt/elastalert/elastalert/elastalert.py\", line 1426, in get_aggregated_matches", " id=match['_id'])", " File \"/root/.local/lib/python2.7/site-packages/elasticsearch/client/utils.py\", line 69, in _wrapped", " return func(args, params=params, *kwargs)", " File \"/root/.local/lib/python2.7/site-packages/elasticsearch/client/__init__.py\", line 714, in delete", " doc_type, id), params=params)", " File \"/root/.local/lib/python2.7/site-packages/elasticsearch/transport.py\", line 327, in perform_request", " status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)", " File \"/root/.local/lib/python2.7/site-packages/elasticsearch/connection/http_requests.py\", line 84, in perform_request", " self._raise_error(response.status_code, raw_data)", " File \"/root/.local/lib/python2.7/site-packages/elasticsearch/connection/base.py\", line 114, in _raise_error", " raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)", "NotFoundError: TransportError(404, u'{\"found\":false,\"_index\":\"elastalert_status\",\"_type\":\"elastalert\",\"_id\":\"AV03DaYQAy_HQqQOgkF2\",\"_version\":3,\"_shards\":{\"total\":2,\"successful\":2,\"failed\":0}}')" ]
I think this could explain the duplicated alerts. Especially this message : Error fetching aggregated matches
Here is elastalert_status index :
{"elastalert_status":{"aliases":{},"mappings":{"past_elastalert":{"properties":{"@timestamp":{"type":"date","format":"dateOptionalTime"},"aggregate_id":{"type":"string","index":"not_analyzed"},"match_body":{"type":"object","enabled":false},"rule_name":{"type":"string","index":"not_analyzed"}}},"silence":{"properties":{"@timestamp":{"type":"date","format":"dateOptionalTime"},"exponent":{"type":"long"},"rule_name":{"type":"string","index":"not_analyzed"},"until":{"type":"date","format":"dateOptionalTime"}}},"elastalert":{"properties":{"@timestamp":{"type":"date","format":"dateOptionalTime"},"aggregate_id":{"type":"string","index":"not_analyzed"},"aggregation_key":{"type":"string"},"alert_exception":{"type":"string"},"alert_info":{"properties":{"command":{"type":"string"},"fir_subject":{"type":"string"},"type":{"type":"string"}}},"alert_sent":{"type":"boolean"},"alert_time":{"type":"date","format":"dateOptionalTime"},"match_body":{"type":"object","enabled":false},"rule_name":{"type":"string","index":"not_analyzed"}}},"elastalert_status":{"properties":{"@timestamp":{"type":"date","format":"dateOptionalTime"},"endtime":{"type":"date","format":"strict_date_optional_time||epoch_millis"},"hits":{"type":"long"},"matches":{"type":"long"},"rule_name":{"type":"string","index":"not_analyzed"},"starttime":{"type":"date","format":"strict_date_optional_time||epoch_millis"},"time_taken":{"type":"double"}}},"elastalert_error":{"properties":{"@timestamp":{"type":"date","format":"dateOptionalTime"},"data":{"type":"object","enabled":false},"message":{"type":"string"},"traceback":{"type":"string"}}}},"settings":{"index":{"creation_date":"1497873925353","number_of_shards":"3","number_of_replicas":"1","uuid":"_JzuSQXFSPOfn_RlTspElg","version":{"created":"2040299"}}},"warmers":{}}}
Note that I have the same behaviour (duplicated alerts) with another alert which is not aggregated (portscan alert)
(I made another test, same issue but no error message about fetching aggregated alerts)
Anybody has the same issue ?
Actually I have the same rules on the two instance of elastalert. I could solve this issue by disabling some rule on the first instance in order to avoid to have the same rules on the second but this would pull down my setup (if one elastalert instance is falling down, the other can take the lead)
@Qmando do you think this could be due to the two instances of elastalert which run queries at the same time (on the same elasticsearch cluster) and are not aware of the alerts already sent for the same event ?
Does elastalert has a way to avoid duplicated alerts in a multi instance environment ?
Hi,
I am also looking for an update on this. Not sure how we can use elastalert HA setup.