# Send value aggregation.payload with kibana watcher

**URL:** <https://discuss.elastic.co/t/send-value-aggregation-payload-with-kibana-watcher/267124>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [March 12, 2021, 8:53pm UTC](https://discuss.elastic.co/t/send-value-aggregation-payload-with-kibana-watcher/267124 "2021-03-12T20:53:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eyler\_Rodrigues](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyler_rodrigues/32/38948_2.png) [@Eyler\_Rodrigues](https://discuss.elastic.co/u/Eyler_Rodrigues)\
**Post date:** [March 12, 2021, 8:53pm UTC](https://discuss.elastic.co/t/send-value-aggregation-payload-with-kibana-watcher/267124/1 "2021-03-12T20:53:47Z")

</div>

Dear, I need help to resolve a question related to the watcher. I created a script with an aggregation and based on a value it sends a message to a webhook.

The result of my script is an example below:

"aggregations": {  
"2": {  
"doc\_count\_error\_upper\_bound": -1,  
"sum\_other\_doc\_count": 258619,  
"buckets": [  
{  
"1": {  
"value": 12  
},  
"doc\_count": 119,  
"key": "xxxxxxxxxx"  
},  
{  
"1": {  
"value": 10  
},  
"doc\_count": 138,  
"key": "xxxxxxxxxx"  
},  
{  
"1": {  
"value": 8  
},  
"doc\_count": 59,  
"key": "xxxxxxxxxxx"  
},  
{  
"1": {  
"value": 6  
},  
"doc\_count": 58,  
"key": "xxxxxxxxxxxxxxx"  
},

I would like to send only the key field and the value field which is the main result of the aggregation, however I am only managing to send the key field and the doc\_count field.

ex: {{#ctx.payload.aggregations.2.buckets}}{{key}}: {{doc\_count}} {{/ctx.payload.aggregations.2.buckets}}'}

Can someone help me.

---

<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:** [April 9, 2021, 8:54pm UTC](https://discuss.elastic.co/t/send-value-aggregation-payload-with-kibana-watcher/267124/2 "2021-04-09T20:54:24Z")

</div>

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