# Alert only on specific Terms

**URL:** <https://forum.opensearch.org/t/alert-only-on-specific-terms/2079>\
**Category:** Alerting\
**Created:** [January 8, 2020, 7:28pm UTC](https://forum.opensearch.org/t/alert-only-on-specific-terms/2079 "2020-01-08T19:28:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kcreddy](https://avatars.discourse-cdn.com/v4/letter/k/6f9a4e/32.png) [@kcreddy](https://forum.opensearch.org/u/kcreddy)\
**Post date:** [January 8, 2020, 7:28pm UTC](https://forum.opensearch.org/t/alert-only-on-specific-terms/2079/1 "2020-01-08T19:28:26Z")

</div>

Hello,

I have a terms aggregation with 2 metrics, where I want to alert only on terms if `metric1 > metric2`  
So, basically it involves iterating over the array `ctx.results[0].hits.hits` and checking the condition for each term.  
When creating Trigger, I can iterate through this array and return true if atleast 1 such term exists.  
But, when sending alert (Action), I only want to list terms which have met the trigger condition and not all the terms. I see that mustache templates can be used inside Action, but how can I filter the terms that met condition?

I see my situation is little bit similar to [this post](https://forum.opensearch.org/t/if-else-in-trigger-action/469) which says there is no way to do it using mustache. But, just checking if anything changed since then or if there is any alternate approach I could take.

---

<div class="post-metadata">

**Author:** ![kris](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/kris/32/2208_2.png) [@kris](https://forum.opensearch.org/u/kris)\
**Post date:** [February 7, 2023, 5:17pm UTC](https://forum.opensearch.org/t/alert-only-on-specific-terms/2079/2 "2023-02-07T17:17:55Z")

</div>


