# Watcher is not generating Email during anomaly

**URL:** <https://discuss.elastic.co/t/watcher-is-not-generating-email-during-anomaly/145670>\
**Category:** Elasticsearch\
**Created:** [August 23, 2018, 7:02am UTC](https://discuss.elastic.co/t/watcher-is-not-generating-email-during-anomaly/145670 "2018-08-23T07:02:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek\_Dwivedi](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@Abhishek\_Dwivedi](https://discuss.elastic.co/u/Abhishek_Dwivedi)\
**Post date:** [August 23, 2018, 7:02am UTC](https://discuss.elastic.co/t/watcher-is-not-generating-email-during-anomaly/145670/1 "2018-08-23T07:02:59Z")

</div>

Hi,  
I am using Single metric ML job to detect an anomaly in my logs. I have also configured WATCHER TO generate EMAIL during any critical anomaly.  
But I found that the single metric viewer is showing 1 critical anomaly but I did not receive an email alert for that.  
In the ES logs I am receiving this message continuously-

[2018-08-23T11:36:29,088][ERROR][o.e.x.w.i.s.ExecutableSearchInput] [node1] failed to execute [search] input for watch [ml-job-iteration14-20aug], reason [cannot write xcontent for unknown value of type class java.time.LocalDateTime]  
[2018-08-23T11:38:14,162][ERROR][o.e.x.w.i.s.ExecutableSearchInput] [node1] failed to execute [search] input for watch [ml-job-iteration14-20aug], reason [cannot write xcontent for unknown value of type class java.time.LocalDateTime]  
[2018-08-23T11:39:59,193][ERROR][o.e.x.w.i.s.ExecutableSearchInput] [node1] failed to execute [search] input for watch [ml-job-iteration14-20aug], reason [cannot write xcontent for unknown value of type class java.time.LocalDateTime]  
[2018-08-23T11:41:43,922][ERROR][o.e.x.w.i.s.ExecutableSearchInput] [node1] failed to execute [search] input for watch [ml-job-iteration14-20aug], reason [cannot write xcontent for unknown value of type class java.time.LocalDateTime]  
[2018-08-23T11:43:29,309][ERROR][o.e.x.w.i.s.ExecutableSearchInput] [node1] failed to execute [search] input for watch [ml-job-iteration14-20aug], reason [cannot write xcontent for unknown value of type class java.time.LocalDateTime]  
[2018-08-23T11:45:13,838][ERROR][o.e.x.w.i.s.ExecutableSearchInput] [node1] failed to execute [search] input for watch [ml-job-iteration14-20aug], reason [cannot write xcontent for unknown value of type class java.time.LocalDateTime]  
[2018-08-23T11:46:58,878][ERROR][o.e.x.w.i.s.ExecutableSearchInput] [node1] failed to execute [search] input for watch [ml-job-iteration14-20aug], reason [cannot write xcontent for unknown value of type class java.time.LocalDateTime]  
[2018-08-23T11:48:43,906][ERROR][o.e.x.w.i.s.ExecutableSearchInput] [node1] failed to execute [search] input for watch [ml-job-iteration14-20aug], reason [cannot write xcontent for unknown value of type class java.time.LocalDateTime]  
[2018-08-23T11:50:28,935][ERROR][o.e.x.w.i.s.ExecutableSearchInput] [node1] failed to execute [search] input for watch [ml-job-iteration14-20aug], reason [cannot write xcontent for unknown value of type class java.time.LocalDateTime]  
[2018-08-23T11:52:13,966][ERROR][o.e.x.w.i.s.ExecutableSearchInput] [node1] failed to execute [search] input for watch [ml-job-iteration14-20aug], reason [cannot write xcontent for unknown value of type class java.time.LocalDateTime]  
[2018-08-23T11:53:59,035][ERROR][o.e.x.w.i.s.ExecutableSearchInput] [node1] failed to execute [search] input for watch [ml-job-iteration14-20aug], reason [cannot write xcontent for unknown value of type class java.time.LocalDateTime]  
[2018-08-23T11:55:44,070][ERROR][o.e.x.w.i.s.ExecutableSearchInput] [node1] failed to execute [search] input for watch [ml-job-iteration14-20aug], reason [cannot write xcontent for unknown value of type class java.time.LocalDateTime]  
[2018-08-23T11:57:29,097][ERROR][o.e.x.w.i.s.ExecutableSearchInput] [node1] failed to execute [search] input for watch [ml-job-iteration14-20aug], reason [cannot write xcontent for unknown value of type class java.time.LocalDateTime]  
[2018-08-23T11:59:14,150][ERROR][o.e.x.w.i.s.ExecutableSearchInput] [node1] failed to execute [search] input for watch [ml-job-iteration14-20aug], reason [cannot write xcontent for unknown value of type class java.time.LocalDateTime]  
[2018-08-23T12:00:59,191][ERROR][o.e.x.w.i.s.ExecutableSearchInput] [node1] failed to execute [search] input for watch [ml-job-iteration14-20aug], reason [cannot write xcontent for unknown value of type class java.time.LocalDateTime]  
[2018-08-23T12:02:44,221][ERROR][o.e.x.w.i.s.ExecutableSearchInput] [node1] failed to execute [search] input for watch [ml-job-iteration14-20aug], reason [cannot write xcontent for unknown value of type class java.time.LocalDateTime]

Is this the reason that I didnt receive email of critical watcher...??  
if no then what is the issue.

During threshold watcher setting I successfully sent the sample email through watcher.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 23, 2018, 8:05am UTC](https://discuss.elastic.co/t/watcher-is-not-generating-email-during-anomaly/145670/2 "2018-08-23T08:05:27Z")

</div>

Hey,

yes that is very likely the reason. This is a bug in Elasticsearch. You can fix this for by modifying the watch and appending `.toString()` at the end of the scripted fields that are calling `LocalDateTime`.

See [https://github.com/elastic/elasticsearch/issues/31853](https://github.com/elastic/elasticsearch/issues/31853) and [https://github.com/elastic/kibana/pull/21998](https://github.com/elastic/kibana/pull/21998)

---

<div class="post-metadata">

**Author:** ![Abhishek\_Dwivedi](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@Abhishek\_Dwivedi](https://discuss.elastic.co/u/Abhishek_Dwivedi)\
**Post date:** [August 28, 2018, 8:08am UTC](https://discuss.elastic.co/t/watcher-is-not-generating-email-during-anomaly/145670/3 "2018-08-28T08:08:06Z")

</div>

Hi Alex,  
Thanks for the support. But where must I make the suggest change i.e where must I append .toString().  
I simply applied the watcher on my ML job that is being run on access log.

---

<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:** [August 29, 2018, 6:59pm UTC](https://discuss.elastic.co/t/watcher-is-not-generating-email-during-anomaly/145670/4 "2018-08-29T18:59:32Z")

</div>

See this for how to edit the watch and insert the .toString()

> [@Machine learning Alerts are failing for java error](https://discuss.elastic.co/t/machine-learning-alerts-are-failing-for-java-error/138629/9):
>
> No, it would be: "start": { "script": { "lang": "painless", "source": """ LocalDateTime.ofEpochSecond((doc["timestamp"].date.getMillis()-((doc["bucket\_span"].value \* 1000) \* params.padding)) / 1000, 0, ZoneOffset.UTC).toString() """, "params": { "padding": 10 } } }, "end": { "script": { "lang": "pa…

---

<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:** [September 26, 2018, 6:59pm UTC](https://discuss.elastic.co/t/watcher-is-not-generating-email-during-anomaly/145670/5 "2018-09-26T18:59:49Z")

</div>

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