# Error executing Watcher Email Action

**URL:** <https://discuss.elastic.co/t/error-executing-watcher-email-action/75798>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [February 20, 2017, 10:14pm UTC](https://discuss.elastic.co/t/error-executing-watcher-email-action/75798 "2017-02-20T22:14:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nielsoncr](https://avatars.discourse-cdn.com/v4/letter/n/c57346/32.png) [@nielsoncr](https://discuss.elastic.co/u/nielsoncr)\
**Post date:** [February 20, 2017, 10:14pm UTC](https://discuss.elastic.co/t/error-executing-watcher-email-action/75798/1 "2017-02-20T22:14:03Z")

</div>

I'm having trouble with a watch action that executes an email on a single node cluster that works just fine on other clusters (all version 2.1.2)

The action looks like this

```
   "actions":{
      "send_email_notification":{
         "throttle_period":"1d",
         "email":{
            "to":["myemail@myemail.com"],
            "subject":"{{ctx.metadata.email_subject}}",
            "body": "HELLO"
            }
        }
   }

```

I know the watch itself is ok because I can create and execute it on a different cluster and it works

On the offending cluster I can see the default account being set

[2017-02-20 21:00:10,366][INFO][watcher.actions.email.service] [master-node-1] default account set to [watcheremail]

my watcher configuration from the elasticsearch.yml looks like this

```
watcher.actions.email.sanitize_html: false
watcher.actions.email.html.sanitization.enabled: false

watcher.actions.email.service.account:
  watcheremail:
    email_defaults:
      from: 'Log Watcher <noreply@mmm.com>'
    smtp:
      host: [my smtp hostname]
      port: 25

```

but when the watch action is triggered I get this in the action result

```
  "actions" : [ {
    "id" : "send_email_notification",
    "type" : "email",
    "status" : "failure",
    "reason" : "NullPointerException[null]"
  } ]

```

and this in the trace log. Rebuilding the cluster is not an option anyone would be happy about.

[2017-02-20 21:00:59,886][ERROR][watcher.actions.email] [master-node-1] failed to execute action [filetransferservice\_error\_status/email\_somebody]  
java.lang.NullPointerException  
at org.elasticsearch.watcher.actions.email.service.Account.send(Account.java:85)  
at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:83)  
at org.elasticsearch.watcher.actions.email.service.InternalEmailService.send(InternalEmailService.java:77)  
at org.elasticsearch.watcher.actions.email.ExecutableEmailAction.execute(ExecutableEmailAction.java:67)  
at org.elasticsearch.watcher.actions.ActionWrapper.execute(ActionWrapper.java:106)  
at org.elasticsearch.watcher.execution.ExecutionService.executeInner(ExecutionService.java:388)  
at org.elasticsearch.watcher.execution.ExecutionService.execute(ExecutionService.java:273)  
at org.elasticsearch.watcher.transport.actions.execute.TransportExecuteWatchAction.masterOperation(TransportExecuteWatchAction.java:130)  
at org.elasticsearch.watcher.transport.actions.execute.TransportExecuteWatchAction.masterOperation(TransportExecuteWatchAction.java:61)  
at org.elasticsearch.action.support.master.TransportMasterNodeAction$3.doRun(TransportMasterNodeAction.java:130)  
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
at java.lang.Thread.run(Thread.java:745)

---

<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:** [February 21, 2017, 8:10am UTC](https://discuss.elastic.co/t/error-executing-watcher-email-action/75798/2 "2017-02-21T08:10:26Z")

</div>

Hey,

is it possible that `localhost` does not resolve properly in your linux setup? Can you try and add a static entry to the `/etc/hosts` file, if resolving has issues?

--Alex

---

<div class="post-metadata">

**Author:** ![nielsoncr](https://avatars.discourse-cdn.com/v4/letter/n/c57346/32.png) [@nielsoncr](https://discuss.elastic.co/u/nielsoncr)\
**Post date:** [February 21, 2017, 1:56pm UTC](https://discuss.elastic.co/t/error-executing-watcher-email-action/75798/3 "2017-02-21T13:56:59Z")

</div>

The actual value in the elasticsearch.yml file is pointing to a functioning corporate smtp server. It works from another cluster so that's not it.

```
host: [my smtp hostname]

```

I did add an entry to the hosts file but no change.

---

<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:** [February 21, 2017, 2:18pm UTC](https://discuss.elastic.co/t/error-executing-watcher-email-action/75798/4 "2017-02-21T14:18:27Z")

</div>

Hey,

just to be sure on my side: Resolving also works for localhost, independently of your SMTP configuration?

Also, any changes in the hosts file will require a restart of your node.

--Alex

---

<div class="post-metadata">

**Author:** ![nielsoncr](https://avatars.discourse-cdn.com/v4/letter/n/c57346/32.png) [@nielsoncr](https://discuss.elastic.co/u/nielsoncr)\
**Post date:** [February 21, 2017, 2:30pm UTC](https://discuss.elastic.co/t/error-executing-watcher-email-action/75798/5 "2017-02-21T14:30:14Z")

</div>

Yes

ping localhost  
PING localhost (127.0.0.1) 56(84) bytes of data.  
64 bytes from localhost (127.0.0.1): icmp\_seq=1 ttl=255 time=0.014 ms  
64 bytes from localhost (127.0.0.1): icmp\_seq=2 ttl=255 time=0.024 ms

---

<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:** [February 21, 2017, 4:29pm UTC](https://discuss.elastic.co/t/error-executing-watcher-email-action/75798/6 "2017-02-21T16:29:46Z")

</div>

Hey,

interesting, so far we only found this exception on Linux systems with resolving issues. One last thing you can try out would be to also add `localhost.localdomain` to the hosts list.

Apart from that, this is fixed in newer versions of watcher, so if you upgrade to the latest, this issue should be gone as well, without requiring/changing any of your setup.

Would love go get to the ground of this anyway to be honest. Will try to think, how to debug this further.

--Alex

---

<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 21, 2017, 4:30pm UTC](https://discuss.elastic.co/t/error-executing-watcher-email-action/75798/7 "2017-03-21T16:30:01Z")

</div>

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