# How can I setup in Watcher to send out an email depend on the Search condition?

**URL:** <https://discuss.elastic.co/t/how-can-i-setup-in-watcher-to-send-out-an-email-depend-on-the-search-condition/208749>\
**Category:** Kibana\
**Created:** [November 20, 2019, 6:10pm UTC](https://discuss.elastic.co/t/how-can-i-setup-in-watcher-to-send-out-an-email-depend-on-the-search-condition/208749 "2019-11-20T18:10:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shaw](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@Shaw](https://discuss.elastic.co/u/Shaw)\
**Post date:** [November 20, 2019, 6:10pm UTC](https://discuss.elastic.co/t/how-can-i-setup-in-watcher-to-send-out-an-email-depend-on-the-search-condition/208749/1 "2019-11-20T18:10:12Z")

</div>

Hi,

In my Watcher, I setup a template below to send out an email base on the search condition, it works. However, I have different Indices and Tags that I want to put all together in one Watcher. For example,

1. If IndexA and TagA have no record, send email with Subject "No IndexA and TagA."
2. If IndexA and TagB have no record, send email with Subject "No IndexA and TagB."
3. If IndexB and TagC have no record, send email with Subject "No IndexB and TagC."
4. If IndexB and TagD have no record, send email with Subject "No IndexB and TagD."

I have tried to add another "input", "condition" and "email" section after the template, but it does not work, how can I accomplish my requirements? Do I need to create each requirement for each Watcher? Please advise.

{  
"trigger": {  
"schedule": {  
...  
},  
"input": {  
"search": {  
...  
},  
"condition": {  
...  
},  
"actions": {  
"send\_email": {  
"email": {  
...  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![LizaD](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lizad/32/51074_2.png) [@LizaD](https://discuss.elastic.co/u/LizaD)\
**Post date:** [November 20, 2019, 6:42pm UTC](https://discuss.elastic.co/t/how-can-i-setup-in-watcher-to-send-out-an-email-depend-on-the-search-condition/208749/2 "2019-11-20T18:42:22Z")

</div>

Hi @Shaw,

Let me see if @alisongoryachev can help here?

Thanks.

---

<div class="post-metadata">

**Author:** ![Shaw](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@Shaw](https://discuss.elastic.co/u/Shaw)\
**Post date:** [November 20, 2019, 6:46pm UTC](https://discuss.elastic.co/t/how-can-i-setup-in-watcher-to-send-out-an-email-depend-on-the-search-condition/208749/3 "2019-11-20T18:46:34Z")

</div>

Thank you @LizaD.

---

<div class="post-metadata">

**Author:** ![alisongoryachev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alisongoryachev/32/111352_2.png) [@alisongoryachev](https://discuss.elastic.co/u/alisongoryachev)\
**Post date:** [November 21, 2019, 2:02am UTC](https://discuss.elastic.co/t/how-can-i-setup-in-watcher-to-send-out-an-email-depend-on-the-search-condition/208749/4 "2019-11-21T02:02:58Z")

</div>

Hi @Shaw! You can only define one `input` and `condition` in the watcher payload.

Would the [chain input](https://www.elastic.co/guide/en/watcher/current/input.html#input-chain) approach help you with this? Also, have you tried using a [script condition](https://www.elastic.co/guide/en/x-pack/current/condition-script.html)?

---

<div class="post-metadata">

**Author:** ![Shaw](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@Shaw](https://discuss.elastic.co/u/Shaw)\
**Post date:** [November 21, 2019, 5:15pm UTC](https://discuss.elastic.co/t/how-can-i-setup-in-watcher-to-send-out-an-email-depend-on-the-search-condition/208749/5 "2019-11-21T17:15:51Z")

</div>

Thank you @alisongoryachev! I will check out the chain input and script condition.

---

<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:** [December 19, 2019, 5:15pm UTC](https://discuss.elastic.co/t/how-can-i-setup-in-watcher-to-send-out-an-email-depend-on-the-search-condition/208749/6 "2019-12-19T17:15:52Z")

</div>

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