# How to put the value of {{ctx.payload.aggregations.bucketAgg.buckets}} into Watcher body

**URL:** https://discuss.elastic.co/t/how-to-put-the-value-of-ctx-payload-aggregations-bucketagg-buckets-into-watcher-body/233815
**Category:** Kibana
**Created:** [May 21, 2020, 9:09pm UTC](https://discuss.elastic.co/t/how-to-put-the-value-of-ctx-payload-aggregations-bucketagg-buckets-into-watcher-body/233815 "2020-05-21T21:09:57Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![vdalvi](https://avatars.discourse-cdn.com/v4/letter/v/54ee81/32.png) [@vdalvi](https://discuss.elastic.co/u/vdalvi)
#### Post date: [May 21, 2020, 9:09pm UTC](https://discuss.elastic.co/t/how-to-put-the-value-of-ctx-payload-aggregations-bucketagg-buckets-into-watcher-body/233815/1 "2020-05-21T21:09:58Z")

</div>

Hi,

I have a watcher created and below is a part of the code. I am trying to parse the result of the "script" from the "perc\_change" bucket in {{ctx.payload.aggregations.bucketAgg.buckets}} to compare it and based on that compare have an email action setup. But I am unable to parse the result of "script". How can I do that and what am I missing in my condition compare ?

```auto
},
                    "perc_change":{
                      "bucket_script": {
                        "buckets_path": {
                          "var1": "count_deriv",
                          "var2":"_count"
                        },
                        "script": "params.var1 / (params.var2 - params.var1) * 100"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "condition" : {
    "compare": {
      "ctx.payload.aggregations.perc_change.buckets" : { "lt" : 0 }
    }
  },

```

---

<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: [June 18, 2020, 9:21pm UTC](https://discuss.elastic.co/t/how-to-put-the-value-of-ctx-payload-aggregations-bucketagg-buckets-into-watcher-body/233815/2 "2020-06-18T21:21:12Z")

</div>

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