# Watcher: getting items into array with condition met

**URL:** <https://discuss.elastic.co/t/watcher-getting-items-into-array-with-condition-met/96815>\
**Category:** Elasticsearch\
**Created:** [August 11, 2017, 7:03pm UTC](https://discuss.elastic.co/t/watcher-getting-items-into-array-with-condition-met/96815 "2017-08-11T19:03:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lean](https://avatars.discourse-cdn.com/v4/letter/l/ac91a4/32.png) [@Lean](https://discuss.elastic.co/u/Lean)\
**Post date:** [August 11, 2017, 7:03pm UTC](https://discuss.elastic.co/t/watcher-getting-items-into-array-with-condition-met/96815/1 "2017-08-11T19:03:58Z")

</div>

Hello again!

I'm playing around watcher and needing some advice here.

I have created a watcher which condition is an array\_compare. Once the condition is met on _some_ of my array values, I need the related action to take _only_ those values and not all of them for reporting purposes.

Could it be done in some way?

Extract of relevant sections follow:

This is my _condition_ section:

```auto
"condition": {
    "array_compare": {
      "ctx.payload.aggregations.group_by_x.buckets": {
        "path": "stats_az.std_deviation",
        "lt": {
          "value": 4e-9,
          "quantifier": "some"
        }
      }
    }
}

```

And this is my _actions_ section:

```auto
"actions": {
    "my-slack-action": {
      "slack": {
        "account": "myacct",
        "message": {
          "from": "watcher",
          "to": [
            "#elastic"
          ],
          "text": "Std dev is {{#ctx.payload.aggregations.group_by_x.buckets}} {{key}}:{{stats_az.std_deviation}} {{/ctx.payload.aggregations.group_by_x.buckets}}"
        }
      }
    }
  }

```

Thank you for your help!  
Leandro.

---

<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 14, 2017, 7:12am UTC](https://discuss.elastic.co/t/watcher-getting-items-into-array-with-condition-met/96815/2 "2017-08-14T07:12:44Z")

</div>

You need to have another processing step that is doing exactly this filtering. This step is called a [transform](https://www.elastic.co/guide/en/x-pack/5.5/transform.html) and should be done with a script transform, that needs to be implemented by yourself.

---

<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:** [September 11, 2017, 7:12am UTC](https://discuss.elastic.co/t/watcher-getting-items-into-array-with-condition-met/96815/3 "2017-09-11T07:12:49Z")

</div>

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