# Adding custom rules for anomaly detection in X-pack

**URL:** <https://discuss.elastic.co/t/adding-custom-rules-for-anomaly-detection-in-x-pack/185410>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-machine-learning\
**Created:** [June 12, 2019, 12:19pm UTC](https://discuss.elastic.co/t/adding-custom-rules-for-anomaly-detection-in-x-pack/185410 "2019-06-12T12:19:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bharath\_Kumar\_R](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bharath_kumar_r/32/45474_2.png) [@Bharath\_Kumar\_R](https://discuss.elastic.co/u/Bharath_Kumar_R)\
**Post date:** [June 12, 2019, 12:19pm UTC](https://discuss.elastic.co/t/adding-custom-rules-for-anomaly-detection-in-x-pack/185410/1 "2019-06-12T12:19:24Z")

</div>

Hey, I'm using X-pack for Anomaly Detection.Is there any way to alter the conditions/rules in my ML job for which the anomaly is detected in my data? For example, i want anomalies to be detected only for zero/null values in my data. i also want anomalies to be detected if no value is input to my ML job

---

<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:** [June 12, 2019, 12:48pm UTC](https://discuss.elastic.co/t/adding-custom-rules-for-anomaly-detection-in-x-pack/185410/2 "2019-06-12T12:48:06Z")

</div>

> **[How to Capture Domain Knowledge in Elastic Machine Learning Jobs with Custom...](https://www.elastic.co/blog/how-to-capture-domain-knowledge-in-elastic-machine-learning-jobs-with-custom-rules)**
>
> Learn how to use custom rules to customize your Elastic machine learning jobs and capture domain expertise for you use case.

---

<div class="post-metadata">

**Author:** ![Bharath\_Kumar\_R](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bharath_kumar_r/32/45474_2.png) [@Bharath\_Kumar\_R](https://discuss.elastic.co/u/Bharath_Kumar_R)\
**Post date:** [June 13, 2019, 10:53am UTC](https://discuss.elastic.co/t/adding-custom-rules-for-anomaly-detection-in-x-pack/185410/3 "2019-06-13T10:53:00Z")

</div>

So, can we modify the rules to detect anomalies if there is no input data to the ML job for a given amount of time?

---

<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:** [June 13, 2019, 11:04am UTC](https://discuss.elastic.co/t/adding-custom-rules-for-anomaly-detection-in-x-pack/185410/4 "2019-06-13T11:04:17Z")

</div>

You don't need a custom rule for that. A simple detection configuration of `low_count` will suffice. If the index you're interested in keeping track of suddenly gets lower input volume than it should, then you'll get an anomaly:

![image](https://us1.discourse-cdn.com/elastic/original/3X/5/3/53f8f74a3871c5c829e27de392f3f25c465635ce.png)

---

<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:** [July 11, 2019, 11:04am UTC](https://discuss.elastic.co/t/adding-custom-rules-for-anomaly-detection-in-x-pack/185410/5 "2019-07-11T11:04:29Z")

</div>

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