# Create custom rule to monitor the logins only in day time?

**URL:** <https://discuss.elastic.co/t/create-custom-rule-to-monitor-the-logins-only-in-day-time/229743>\
**Category:** SIEM\
**Created:** [April 25, 2020, 5:45am UTC](https://discuss.elastic.co/t/create-custom-rule-to-monitor-the-logins-only-in-day-time/229743 "2020-04-25T05:45:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Blason](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/blason/32/42284_2.png) [@Blason](https://discuss.elastic.co/u/Blason)\
**Post date:** [April 25, 2020, 5:45am UTC](https://discuss.elastic.co/t/create-custom-rule-to-monitor-the-logins-only-in-day-time/229743/1 "2020-04-25T05:45:50Z")

</div>

Hey Guys,

I am creating my custom rule to monitor the filebeat-\* events to monitor login events only between 09:00 to 20:00. And needs to send an alert if any event happens after the said period. Can we do that with custom rules?

Can someone pls advise?

---

<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:** [April 27, 2020, 3:52pm UTC](https://discuss.elastic.co/t/create-custom-rule-to-monitor-the-logins-only-in-day-time/229743/2 "2020-04-27T15:52:37Z")

</div>

If you're only looking for login events between some period of time you might be able to use date math like so:

```auto
@timestamp >= "now/d+9h" and @timestamp <= "now/d+20h"

```

See here:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math)

I tried it out with a rule and it looked like it worked against some filebeat data I had and produced results between 9 and 20 hours running.

---

<div class="post-metadata">

**Author:** ![Blason](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/blason/32/42284_2.png) [@Blason](https://discuss.elastic.co/u/Blason)\
**Post date:** [April 28, 2020, 3:44am UTC](https://discuss.elastic.co/t/create-custom-rule-to-monitor-the-logins-only-in-day-time/229743/3 "2020-04-28T03:44:12Z")

</div>

Dang why I didnt think of that but thanks for the clue buddy!!.

let me try that.

---

<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:** [May 26, 2020, 3:44am UTC](https://discuss.elastic.co/t/create-custom-rule-to-monitor-the-logins-only-in-day-time/229743/4 "2020-05-26T03:44:14Z")

</div>

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

---

<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:** [May 26, 2020, 3:44am UTC](https://discuss.elastic.co/t/create-custom-rule-to-monitor-the-logins-only-in-day-time/229743/5 "2020-05-26T03:44:16Z")

</div>



---

<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, 7:55am UTC](https://discuss.elastic.co/t/create-custom-rule-to-monitor-the-logins-only-in-day-time/229743/6 "2022-11-04T07:55:29Z")

</div>


