# Kibana alert rules use today only time window

**URL:** https://discuss.elastic.co/t/kibana-alert-rules-use-today-only-time-window/333184
**Category:** Kibana
**Tags:** elastic-stack-alerting
**Created:** [May 11, 2023, 10:00am UTC](https://discuss.elastic.co/t/kibana-alert-rules-use-today-only-time-window/333184 "2023-05-11T10:00:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mikhatanu](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@mikhatanu](https://discuss.elastic.co/u/mikhatanu)
#### Post date: [May 11, 2023, 10:00am UTC](https://discuss.elastic.co/t/kibana-alert-rules-use-today-only-time-window/333184/1 "2023-05-11T10:00:08Z")

</div>

Hello, i would like to create a rule that uses only today time window (from 00:00 to 24:00), not the last one day. for example, the rule is triggered every 15 minutes. The first check will be at 00:15 and uses time window 00:00 to 00:15 . At 12 check noon, the time window will be 00:00 to 12:00. At 8 night check, the time window is 00:00 to 20:00. At 24:00 check, it will use the whole day 00:00 to 24:00. After that, it will reset back to the first check the next day. Is this possible?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/1/8147f80a56f57016aa442d36ac1d220f74d07923.png)

---

<div class="post-metadata">

### Author: ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)
#### Post date: [May 31, 2023, 10:52pm UTC](https://discuss.elastic.co/t/kibana-alert-rules-use-today-only-time-window/333184/2 "2023-05-31T22:52:01Z")

</div>

You can add a filter to the "Define your query" section that does date math to get the time range you want.

See [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html#ranges-on-dates](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html#ranges-on-dates)

In this case, you can add a filter on the `@timestamp` field that sets a range between the beginning of the day, and "now".

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/2/92adfa226310aaf033eda2ee6b26fae57ac56efc.jpeg)

In the "For the last" clause, you will want to choose the last 24 hours, as sometimes the time filter will calculate out to a range of that size.

Hope this helps!

---

<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: [June 28, 2023, 10:52pm UTC](https://discuss.elastic.co/t/kibana-alert-rules-use-today-only-time-window/333184/3 "2023-06-28T22:52:20Z")

</div>

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