# Threshold Rule for Detecting Brute force Attacks

**URL:** https://discuss.elastic.co/t/threshold-rule-for-detecting-brute-force-attacks/245866
**Category:** Elastic Security
**Created:** [August 21, 2020, 7:20am UTC](https://discuss.elastic.co/t/threshold-rule-for-detecting-brute-force-attacks/245866 "2020-08-21T07:20:14Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Ameer\_Mukadam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ameer_mukadam/32/47196_2.png) [@Ameer\_Mukadam](https://discuss.elastic.co/u/Ameer_Mukadam)
#### Post date: [August 21, 2020, 7:20am UTC](https://discuss.elastic.co/t/threshold-rule-for-detecting-brute-force-attacks/245866/1 "2020-08-21T07:20:14Z")

</div>

Hi, with the release of 7.9 I tried creating a threshold rule for detecting and alerting Windows Brute Force Attacks. The query is Event.code 4625 and the threshold field is host.name greater than equal to 5.  
But the rule isn't detecting anything.

---

<div class="post-metadata">

### Author: ![threatpunter](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@threatpunter](https://discuss.elastic.co/u/threatpunter)
#### Post date: [August 21, 2020, 9:02pm UTC](https://discuss.elastic.co/t/threshold-rule-for-detecting-brute-force-attacks/245866/2 "2020-08-21T21:02:51Z")

</div>

Thanks for reaching out @Ameer_Mukadam. I have some questions for you to try and help identify the problem.

Are you using Winlogbeat to ship Windows security event logs to Elasticsearch? If so, what version of Winlogbeat are you using?

If you execute the following query in Discover under the `winlogbeat-*` index pattern, do you see 5 or more events within the time window that you specified in the threshold rule? This is to check that the events are present in order to trigger your rule.

`event.code:4625`

Does your rule look similar to my example in the screenshot below?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/1/71547cb44b035f5a16deedcde15559a42aa383a4.png)

How have you configured the schedule for your rule? In my example below, I've set the interval to 5 minutes and the additional look-back time to 1 minute.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/9/d9904980f6979434dec9a45ed097bed8adf69272.png)

I'll keep an eye out for your response. Thanks

---

<div class="post-metadata">

### Author: ![Ameer\_Mukadam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ameer_mukadam/32/47196_2.png) [@Ameer\_Mukadam](https://discuss.elastic.co/u/Ameer_Mukadam)
#### Post date: [August 22, 2020, 5:38am UTC](https://discuss.elastic.co/t/threshold-rule-for-detecting-brute-force-attacks/245866/3 "2020-08-22T05:38:12Z")

</div>

Yes my rule looks exactly the same. Tuned the schedule and it started working thank you very much.

---

<div class="post-metadata">

### Author: ![threatpunter](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@threatpunter](https://discuss.elastic.co/u/threatpunter)
#### Post date: [August 22, 2020, 5:03pm UTC](https://discuss.elastic.co/t/threshold-rule-for-detecting-brute-force-attacks/245866/4 "2020-08-22T17:03:55Z")

</div>

Great! I'm glad you got it working 🙂

---

<div class="post-metadata">

### Author: ![siiman](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@siiman](https://discuss.elastic.co/u/siiman)
#### Post date: [October 1, 2020, 11:24am UTC](https://discuss.elastic.co/t/threshold-rule-for-detecting-brute-force-attacks/245866/5 "2020-10-01T11:24:41Z")

</div>

Hello Ameer,

how did you tuned the schedule? I have exactly the same problem and can't find any error.  
I also use version 7.9.0

Thanks for your help.  
kind regards  
siiman

---

<div class="post-metadata">

### Author: ![Ameer\_Mukadam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ameer_mukadam/32/47196_2.png) [@Ameer\_Mukadam](https://discuss.elastic.co/u/Ameer_Mukadam)
#### Post date: [October 6, 2020, 7:55am UTC](https://discuss.elastic.co/t/threshold-rule-for-detecting-brute-force-attacks/245866/6 "2020-10-06T07:55:18Z")

</div>

Hey, I didn’t do anything specific suddenly it just started working.

---

<div class="post-metadata">

### Author: ![Frank\_Hassanabad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/frank_hassanabad/32/49255_2.png) [@Frank\_Hassanabad](https://discuss.elastic.co/u/Frank_Hassanabad)
#### Post date: [October 7, 2020, 9:20pm UTC](https://discuss.elastic.co/t/threshold-rule-for-detecting-brute-force-attacks/245866/7 "2020-10-07T21:20:48Z")

</div>

Just throwing this out there @siiman and @Ameer_Mukadam about at least one reason why sometimes if you tweak the scheduling things start working when before they looked like they didn't. This might/might not be an explanation but it's good to know nonetheless for the future.

When you create a rule and set the schedule and then run it, the rule by default will look at the `@timestamp` for its queries to detect things from the scheduler. If your agents such as beats or endgame or etc... are sending events where the `@timestamp` is off because that computer sending the message has clock skew you're going to start to see this type of behavior where you're sometimes not detecting things between rule runs.

The additional look back time is used to account for some clock skew by intentionally doing a small overlap along with signal de-duplication between the overlaps. We have seen people change this value and then start to see signals occurring when before they might not have.

 ![Screen Shot 2020-10-07 at 3.15.00 PM](https://us1.discourse-cdn.com/elastic/original/3X/4/7/47e8156493e5f1bbb207dc02abc1442df540af6f.png)

The worst offenders of the clock skew is that some systems run different log collectors/log proxies which happen to have received a batch of logs with timestamp already set to a past time but it basically processes them to Elastic Search in bursts or periodic times and then the clock skew issue deepens for people.

A feature we have if this is the case is to utilize the timestamp override we have and choose a field that you setup server side in a pipeline processor[1] to add a date time field of when it arrives within ES such as event.ingested:

 ![Screen Shot 2020-10-07 at 3.12.46 PM](https://us1.discourse-cdn.com/elastic/original/3X/d/6/d62f5fbf82f6a09ff2a97f83ae1e38e5781242c5.png)

Refs:

1. [https://www.elastic.co/guide/en/elasticsearch/reference/master/ingest-processors.html](https://www.elastic.co/guide/en/elasticsearch/reference/master/ingest-processors.html)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [November 4, 2022, 8:10am UTC](https://discuss.elastic.co/t/threshold-rule-for-detecting-brute-force-attacks/245866/8 "2022-11-04T08:10:55Z")

</div>


