# \[Kibana\]\[Machine learning\]Custom Rule

**URL:** <https://discuss.elastic.co/t/kibana-machine-learning-custom-rule/166809>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-machine-learning\
**Created:** [February 2, 2019, 7:11am UTC](https://discuss.elastic.co/t/kibana-machine-learning-custom-rule/166809 "2019-02-02T07:11:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hyhong](https://avatars.discourse-cdn.com/v4/letter/h/3bc359/32.png) [@hyhong](https://discuss.elastic.co/u/hyhong)\
**Post date:** [February 2, 2019, 7:11am UTC](https://discuss.elastic.co/t/kibana-machine-learning-custom-rule/166809/1 "2019-02-02T07:11:55Z")

</div>

When I use Machine learning , I need write myself rule , I just see the conditions is number,I need the time range , how can I use by conditions.

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

---

<div class="post-metadata">

**Author:** ![BenTrent](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bentrent/32/33915_2.png) [@BenTrent](https://discuss.elastic.co/u/BenTrent)\
**Post date:** [February 4, 2019, 1:34pm UTC](https://discuss.elastic.co/t/kibana-machine-learning-custom-rule/166809/2 "2019-02-04T13:34:45Z")

</div>

@hyhong

You can specify a time range by supplying the time as Seconds since the Epoch and setting `applies_to: time`

Example, applies the rule according to the time field where it is after than `October 30, 2018 1:32:20 PM`

```auto
"conditions": [
   {
      "applies_to": "time",
      "operator": "gt",
      "value": 1540906340
   }
]

```

---

<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:** [February 4, 2019, 2:31pm UTC](https://discuss.elastic.co/t/kibana-machine-learning-custom-rule/166809/3 "2019-02-04T14:31:06Z")

</div>

While the above is true, this is typically not the way that people ignore time periods. More common ways are to:

1. control the start/stop time of the datafeed: [https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html)

2. defining calendar events to have the job ignore time periods: [https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-calendar-event.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-calendar-event.html)

---

<div class="post-metadata">

**Author:** ![hyhong](https://avatars.discourse-cdn.com/v4/letter/h/3bc359/32.png) [@hyhong](https://discuss.elastic.co/u/hyhong)\
**Post date:** [February 11, 2019, 1:00am UTC](https://discuss.elastic.co/t/kibana-machine-learning-custom-rule/166809/4 "2019-02-11T01:00:36Z")

</div>

Thanks,but the time range is change.For example,from 00:00 to 09:00 every day.

---

<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:** [March 11, 2019, 1:00am UTC](https://discuss.elastic.co/t/kibana-machine-learning-custom-rule/166809/5 "2019-03-11T01:00:38Z")

</div>

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