# Watcher Email configuration Issue

**URL:** <https://discuss.elastic.co/t/watcher-email-configuration-issue/33047>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [October 27, 2015, 6:21am UTC](https://discuss.elastic.co/t/watcher-email-configuration-issue/33047 "2015-10-27T06:21:40Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![vbi517](https://avatars.discourse-cdn.com/v4/letter/v/46a35a/32.png) [@vbi517](https://discuss.elastic.co/u/vbi517)\
**Post date:** [July 12, 2016, 11:44am UTC](https://discuss.elastic.co/t/watcher-email-configuration-issue/33047/21 "2016-07-12T11:44:03Z")

</div>

I am getting error like...

{"error":{"root\_cause":[{"type":"i\_o\_exception","reason":"could not parse watch  
[log\_error\_watch]"}],"type":"i\_o\_exception","reason":"could not parse watch [log  
\_error\_watch]","caused\_by":{"type":"json\_parse\_exception","reason":"Unexpected c  
haracter ('"' (code 34)): was expecting comma to separate OBJECT entries\n at [  
Source: org.elasticsearch.transport.netty.ChannelBufferStreamInput@7f49033c; lin  
e: 12, column: 2]"}},"status":500}

---

<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:** [July 12, 2016, 1:00pm UTC](https://discuss.elastic.co/t/watcher-email-configuration-issue/33047/22 "2016-07-12T13:00:07Z")

</div>

Hey,

note that one of you talks about a search input and the other shows examples of a http input, which have different options...

--Alex

---

<div class="post-metadata">

**Author:** ![vbi517](https://avatars.discourse-cdn.com/v4/letter/v/46a35a/32.png) [@vbi517](https://discuss.elastic.co/u/vbi517)\
**Post date:** [July 12, 2016, 1:03pm UTC](https://discuss.elastic.co/t/watcher-email-configuration-issue/33047/23 "2016-07-12T13:03:14Z")

</div>

Hi Ganeshprabhu/Alex,

I am trying to create watch with search input using following code....

curl -XPUT '[http://localhost:9200/\_watcher/watch/log\_error\_watch](http://localhost:9200/_watcher/watch/log_error_watch)' -d '{  
"trigger" : { "schedule" : { "interval" : "20s" } },  
"input" : {  
"search" : {  
"request" : {  
"indices" : ["logs"],  
"body" : {  
"query" : {  
"match" : { "message": "error" }  
}  
}  
}  
},  
"auth": {  
"basic": {  
"username": "vijaykumar@xyz.com",  
"password": "xyz123"  
}  
}  
},  
"condition" : {  
"compare" : { "ctx.payload.hits.total" : { "gt" : 0 }}  
},  
"actions" : {  
"send\_email" : {  
"email" : {  
"to" : "xyz@abc.com",  
"subject" : "Watcher Notification",  
"body" : "{{ctx.payload.hits.total}} watches took more than 2.5 seconds to execute.",  
"attachments" : {  
"data\_attachments" : {  
"data" : {  
"format" : "json"  
}  
}  
}  
}  
}  
}  
}'

But i am getting error like...  
{"error":{"root\_cause":[{"type":"parse\_exception","reason":"could not parse inpu  
t for watch [log\_error\_watch]. unknown input type [auth]"}],"type":"parse\_except  
ion","reason":"could not parse input for watch [log\_error\_watch]. unknown input  
type [auth]"},"status":400}

please suggest me with valid inputs....

---

<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:** [July 12, 2016, 1:08pm UTC](https://discuss.elastic.co/t/watcher-email-configuration-issue/33047/24 "2016-07-12T13:08:35Z")

</div>

please take your time to read the exceptions. It explains that `auth` is not an input type, because you mis-structured your JSON. Please use a UI like sense or a JSON formatter to be aware of the structure.

Also please post the output of the execute watch API, once you successfully added the watch and executed it to take a further look.

---

<div class="post-metadata">

**Author:** ![eds](https://avatars.discourse-cdn.com/v4/letter/e/bc79bd/32.png) [@eds](https://discuss.elastic.co/u/eds)\
**Post date:** [August 3, 2016, 2:50pm UTC](https://discuss.elastic.co/t/watcher-email-configuration-issue/33047/25 "2016-08-03T14:50:12Z")

</div>

Greetings!  
I'm new to ELK and i need some help.  
I'm having the same issue (cannot find default email account), and i don't seem to understand where's my syntax error here?

Elasticsearch log error:  
[2016-08-03 17:06:55,980][ERROR][xpack.watcher.actions.email] [Shadowcat] failed to execute action [log\_error\_watch/send\_email]  
java.lang.IllegalStateException: cannot find default email account as no accounts have been configured  
at org.elasticsearch.xpack.notification.email.Accounts.account(Accounts.java:72)  
at org.elasticsearch.xpack.notification.email.InternalEmailService.send(InternalEmailService.java:73)  
at org.elasticsearch.xpack.watcher.actions.email.ExecutableEmailAction.execute(ExecutableEmailAction.java:85)  
at org.elasticsearch.xpack.watcher.actions.ActionWrapper.execute(ActionWrapper.java:109)  
at org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:397)  
at org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:280)  
at org.elasticsearch.xpack.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:450)  
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:392)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)  
at java.lang.Thread.run(Thread.java:745)  
[2016-08-03 17:06:57,154][ERROR][xpack.watcher.actions.email] [Shadowcat] failed to execute action [log\_error\_watch/send\_email]  
java.lang.IllegalStateException: cannot find default email account as no accounts have been configured  
at org.elasticsearch.xpack.notification.email.Accounts.account(Accounts.java:72)

Sense error:  
"actions": [  
{  
"id": "send\_email",  
"type": "email",  
"status": "failure",  
"reason": "IllegalStateException[cannot find default email account as no accounts have been configured]"  
}  
]

# ================================= Configuration: elasticsearch 5.0 alpha 4 + xpack 5.0 alpha + winlogbeat 5.0 alpha 4

# YML: xpack.notification.email.service.account: exchange\_account: profile: outlook email\_defaults: from: 'alerts [mail@mail.com](mailto:mail@mail.com)' smtp: auth: true host: 192.168.1.1 password: mail\_pass port: 587 starttls.enable: true user: [mail@mail.com](mailto:mail@mail.com)

Test watcher:  
{  
"trigger" : { "schedule" : { "interval" : "30s" }},  
"input" : {  
"search" : {  
"request" : {  
"indices" : "winlogbeat\*",  
"body" : {  
"query" : {  
"match" : { "message": "error" }  
}  
}  
}  
}  
},  
"condition" : {  
"compare" : { "ctx.payload.hits.total" : { "gt" : 0 }}  
},  
"actions" : {  
"send\_email" : {  
"email" : {  
"to" : "adm@mail.com",  
"subject" : "log error watch",  
"body" : "Found {{ctx.payload.hits.total}} errors in the logs"  
}  
}  
}  
}

Much thanks!  
dmitry

---

<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 3, 2016, 3:04pm UTC](https://discuss.elastic.co/t/watcher-email-configuration-issue/33047/26 "2016-08-03T15:04:55Z")

</div>

Hey,

try `xpack.notification.email:` instead of `xpack.notification.email.service.account:` - see [https://www.elastic.co/guide/en/x-pack/v5.0.0-alpha4-docs/actions-email.html#configuring-email](https://www.elastic.co/guide/en/x-pack/v5.0.0-alpha4-docs/actions-email.html#configuring-email)

--Alex

---

<div class="post-metadata">

**Author:** ![eds](https://avatars.discourse-cdn.com/v4/letter/e/bc79bd/32.png) [@eds](https://discuss.elastic.co/u/eds)\
**Post date:** [August 4, 2016, 5:55am UTC](https://discuss.elastic.co/t/watcher-email-configuration-issue/33047/27 "2016-08-04T05:55:28Z")

</div>

Hi Alex!  
Thanks for your response!!  
xpack.notification.email: not working.  
I'm getting the same error:  
cannot find default email account as no accounts have been configured

---

<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 4, 2016, 6:14am UTC](https://discuss.elastic.co/t/watcher-email-configuration-issue/33047/28 "2016-08-04T06:14:53Z")

</div>

Can you please show your exact configuration including indentation? (Just put the config file in three backticks for code formatting, see the markdown specs)... this might help to spot issues

--Alex

---

<div class="post-metadata">

**Author:** ![eds](https://avatars.discourse-cdn.com/v4/letter/e/bc79bd/32.png) [@eds](https://discuss.elastic.co/u/eds)\
**Post date:** [August 5, 2016, 6:04am UTC](https://discuss.elastic.co/t/watcher-email-configuration-issue/33047/29 "2016-08-05T06:04:36Z")

</div>

YML file:

```auto
# ---------------------------------- X-Pack -----------------------------------
#
# Disable shield
xpack.security.enabled: false
#
# mail settings
xpack.notification.email:
    exchange_account:
        profile: outlook
        email_defaults:
            from: 'alerts <mail@mail.com>'
        smtp:
            auth: true
            host: 192.168.1.1
            password: mail_pass
            port: 587
            starttls.enable: true
            user: mail@mail.com

```

---

<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 5, 2016, 7:40am UTC](https://discuss.elastic.co/t/watcher-email-configuration-issue/33047/30 "2016-08-05T07:40:37Z")

</div>

Hey,

can you try `xpack.notification.email.account:` instead of `xpack.notification.email:`

--Alex

---

<div class="post-metadata">

**Author:** ![eds](https://avatars.discourse-cdn.com/v4/letter/e/bc79bd/32.png) [@eds](https://discuss.elastic.co/u/eds)\
**Post date:** [August 5, 2016, 8:20am UTC](https://discuss.elastic.co/t/watcher-email-configuration-issue/33047/31 "2016-08-05T08:20:13Z")

</div>

Alex!!! IT'S WORKING!!!  
Thanks very much!  
YML:

```auto
# ---------------------------------- X-Pack -----------------------------------
#
# Disable shield
xpack.security.enabled: false
#
# mail settings
xpack.notification.email.account:
    exchange_account:
        profile: outlook
        email_defaults:
            from: 'alerts <mail@mail.com>'
        smtp:
            auth: false
            host: 192.168.1.1
            # password: mail_pass
            port: 25
            # starttls.enable: true
            # user: mail@mail.com

```

---

<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 5, 2016, 8:57am UTC](https://discuss.elastic.co/t/watcher-email-configuration-issue/33047/32 "2016-08-05T08:57:53Z")

</div>

very nice!

I will update the documentation to be more exact, so other dont run into this. Thanks for getting back!

--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:** [July 6, 2017, 1:43pm UTC](https://discuss.elastic.co/t/watcher-email-configuration-issue/33047/33 "2017-07-06T13:43:40Z")

</div>

Closed on July 6, 2017, 1:43pm UTC



[Previous page](https://discuss.elastic.co/t/watcher-email-configuration-issue/33047.md?page=1)
