# Elastalert2 reaalert every 5 minutes and group the number of hits

**URL:** <https://discuss.elastic.co/t/elastalert2-reaalert-every-5-minutes-and-group-the-number-of-hits/309710>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [July 15, 2022, 7:30am UTC](https://discuss.elastic.co/t/elastalert2-reaalert-every-5-minutes-and-group-the-number-of-hits/309710 "2022-07-15T07:30:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![navin1093](https://avatars.discourse-cdn.com/v4/letter/n/e47c2d/32.png) [@navin1093](https://discuss.elastic.co/u/navin1093)\
**Post date:** [July 15, 2022, 7:30am UTC](https://discuss.elastic.co/t/elastalert2-reaalert-every-5-minutes-and-group-the-number-of-hits/309710/1 "2022-07-15T07:30:07Z")

</div>

Seeking your advice and help.

Currently my Heartbeat will monitor system health for every 5 minutes. Then, it will save the data to Elasticsearch. My Elastalert2 will retrieve the date from Elasticsearch.

I have 2 system being monitored

- Application 1
- Application 2

Below is my expectations

- monitor every 5 minutes and if it hit 6 down for group or individual of 6 hits for past 30 minutes to trigger and alert

Below is my Elastalert2 code  
config.yml

```auto
run_every:
  minutes: 1
buffer_time:
  minutes: 5

```

rule.yml

```auto
type: "frequency"
index: "filebeat-*"
realert:
  minutes: 5
num_events: 6
timeframe:
  minutes: 30
filter:
  - term:
      monitor.status.keyword : "down"
  - terms:
      monitor.id.keyword : ["Application-1", "Application-2"]

```

Let's say below is the timing the Elastalert2 executed

```auto
5:00
5:05
5:10
5:15
5:20
5:25
5:30
5:35

```

and let's say below is the timing the Heartbeat executed

```auto
5:00
5:05
5:10
5:15
5:20
5:25
5:30
5:35

```

Not what it happens is that

- It is counting number of hits separately as Application-1 as 3 hits and Application-2 as 3 hits causing it to trigger alert at 5:10 rather than grouping together as Application-1 and Application-2 as 6 hits and trigger alert at 5:25

Also once it trigger alert, it wait for anotehr 6 even to trigger. I want it to count from current time to last 30 minutes do the checking and trigger allert. Example 5:25, 5:30, 5:35 as the system is still down for the past 30 minutes form current time

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 15, 2022, 7:38am UTC](https://discuss.elastic.co/t/elastalert2-reaalert-every-5-minutes-and-group-the-number-of-hits/309710/2 "2022-07-15T07:38:36Z")

</div>

Elastalert is a third party component which is not supported here. I would recommend you reach out to the creators directly.

---

<div class="post-metadata">

**Author:** ![navin1093](https://avatars.discourse-cdn.com/v4/letter/n/e47c2d/32.png) [@navin1093](https://discuss.elastic.co/u/navin1093)\
**Post date:** [July 15, 2022, 3:50pm UTC](https://discuss.elastic.co/t/elastalert2-reaalert-every-5-minutes-and-group-the-number-of-hits/309710/3 "2022-07-15T15:50:21Z")

</div>

noted with thanks

---

<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:** [August 12, 2022, 3:50pm UTC](https://discuss.elastic.co/t/elastalert2-reaalert-every-5-minutes-and-group-the-number-of-hits/309710/4 "2022-08-12T15:50:41Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
