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.