Rule with term, aggregation and count
Hello everyone,
Firstly thanks @Qmando for this tool, it's very useful.
I would like to create a rule to see if someone is doing authentification bruteforce on email address. To do this, I want to watch if during a period of time (5 minutes) the user failed his password more than 3 times. To see if a user failed to login, I already have a field "event.action" == "UserLoginFailed". Then I would like to send only one alert per User.
Example : In a range of 5 minutes : Mister Betty has failed her password 5 times. Mister Smith has failed his password 4 times. Mister Bob has failed his password 2 times.
I want to receive 2 alerts (one for Mister Betty and the other for Smith)
I've try a lot of things but I didn't success to do this.
I've made it with kibana Query DSL like that :
GET xxx/_search { "query": { "bool": { "filter": [ { "term": {"event.action.keyword": "UserLoginFailed"} }, { "range": { "@timestamp": { "gte": "now-5m" } } } ] } }, "size" :0, "aggs": { "test": { "terms": { "field": "user.id.keyword" }, "aggs": { "filter_doc_count": { "bucket_selector": { "buckets_path": { "doc_count": "_count" }, "script": "params.doc_count > 3" } } } } } }
Thanks a lot,
Yelp/elastalert is no longer maintained. Please use jertel/elastalert. Questions to the discussion below https://github.com/jertel/elastalert/discussions