# Alerting on a specific time range

**URL:** https://discuss.elastic.co/t/alerting-on-a-specific-time-range/266999
**Category:** Kibana
**Tags:** elastic-stack-machine-learning, elastic-stack-alerting
**Created:** [March 11, 2021, 8:51pm UTC](https://discuss.elastic.co/t/alerting-on-a-specific-time-range/266999 "2021-03-11T20:51:45Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ElasticLiver](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticliver/32/64869_2.png) [@ElasticLiver](https://discuss.elastic.co/u/ElasticLiver)
#### Post date: [March 11, 2021, 8:51pm UTC](https://discuss.elastic.co/t/alerting-on-a-specific-time-range/266999/1 "2021-03-11T20:51:45Z")

</div>

Hi is there a way to alert only on a specific time range? lets say office hours....  
It is possible? how can I do this?

---

<div class="post-metadata">

### Author: ![wei.wang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wei.wang/32/51803_2.png) [@wei.wang](https://discuss.elastic.co/u/wei.wang)
#### Post date: [March 12, 2021, 4:32am UTC](https://discuss.elastic.co/t/alerting-on-a-specific-time-range/266999/2 "2021-03-12T04:32:42Z")

</div>

Hi there,

Before we start here, first I want to make sure I understand your question correctly.

> [@ElasticLiver](#):
>
> alert only on a specific time range

1. You want your ml watcher only to query on specific time range , like office hours, which means you don't want to be notified about the anomalies out of that time range, like weekends.

or

1. You only want to receive the alerting during office hours.

Thanks.

---

<div class="post-metadata">

### Author: ![richcollier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richcollier/32/115035_2.png) [@richcollier](https://discuss.elastic.co/u/richcollier)
#### Post date: [March 12, 2021, 12:15pm UTC](https://discuss.elastic.co/t/alerting-on-a-specific-time-range/266999/3 "2021-03-12T12:15:10Z")

</div>

Actually, it is not apparent that this question has anything to do with ML, just alerting. Can you confirm @ElasticLiver

---

<div class="post-metadata">

### Author: ![ElasticLiver](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticliver/32/64869_2.png) [@ElasticLiver](https://discuss.elastic.co/u/ElasticLiver)
#### Post date: [March 12, 2021, 12:44pm UTC](https://discuss.elastic.co/t/alerting-on-a-specific-time-range/266999/4 "2021-03-12T12:44:30Z")

</div>

The first option, the watcher to query only on specific time range

---

<div class="post-metadata">

### Author: ![richcollier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richcollier/32/115035_2.png) [@richcollier](https://discuss.elastic.co/u/richcollier)
#### Post date: [March 12, 2021, 1:52pm UTC](https://discuss.elastic.co/t/alerting-on-a-specific-time-range/266999/5 "2021-03-12T13:52:19Z")

</div>

It would be some logic using `range` in the query or a dynamic script. See ideas here: [How to filter date field by days and hours separately](https://discuss.elastic.co/t/how-to-filter-date-field-by-days-and-hours-separately/193946)

You could also consider using runtime fields ([Retrieve a runtime field | Elasticsearch Reference [7.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/runtime-retrieving-fields.html)) to define day of the week or hour of day (or both) and then filter your query on 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: [April 9, 2021, 1:53pm UTC](https://discuss.elastic.co/t/alerting-on-a-specific-time-range/266999/6 "2021-04-09T13:53:07Z")

</div>

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