# Watcher Assistance

**URL:** https://discuss.elastic.co/t/watcher-assistance/259919
**Category:** Elasticsearch
**Tags:** elastic-stack-alerting, painless
**Created:** [December 30, 2020, 8:53pm UTC](https://discuss.elastic.co/t/watcher-assistance/259919 "2020-12-30T20:53:40Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![PinkElephant](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@PinkElephant](https://discuss.elastic.co/u/PinkElephant)
#### Post date: [December 30, 2020, 8:53pm UTC](https://discuss.elastic.co/t/watcher-assistance/259919/1 "2020-12-30T20:53:40Z")

</div>

Am trying to loop through a particular aggregation bucket-by-bucket and check if its corresponding key matches the value of ctx.payload.second.hits.hits.0.\_source.host.hostname.

If it matches (and the hits total is \> 0 for each input), I'd like to have it execute. Been trying to use script condition, but am not finding success.

I'm using a chain input with two inputs ("first" and "second", respectively) and cannot seem to find the correct syntax.

Any help / example would be appreciated.

---

<div class="post-metadata">

### Author: ![PinkElephant](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@PinkElephant](https://discuss.elastic.co/u/PinkElephant)
#### Post date: [December 31, 2020, 8:35pm UTC](https://discuss.elastic.co/t/watcher-assistance/259919/2 "2020-12-31T20:35:28Z")

</div>

After a lot of trial and error, believe I found the culprit. (It's compiling now, but need to test it)

Would still love a reply, in the event that I've got a logic error. If there's any way that I can make this post more clear, please LMK.

---

<div class="post-metadata">

### Author: ![PinkElephant](https://avatars.discourse-cdn.com/v4/letter/p/e5b9ba/32.png) [@PinkElephant](https://discuss.elastic.co/u/PinkElephant)
#### Post date: [January 1, 2021, 5:10am UTC](https://discuss.elastic.co/t/watcher-assistance/259919/3 "2021-01-01T05:10:19Z")

</div>

OK, I ended up fixing it. You may close out this topic! Happy New Year.

---

<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: [January 29, 2021, 5:10am UTC](https://discuss.elastic.co/t/watcher-assistance/259919/4 "2021-01-29T05:10:19Z")

</div>

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