Hello
What i am trying to do is to hand over the value of
"{{ctx.payload.aggregations.bucketAgg.buckets.key}}"
to the body of my Watcher.
However, the value is always empty. But in truth it is not!
Here you can see the relevant part of my request:
"actions": {
"mobots_webhook": {
"webhook": {
"scheme": "https",
"host": "www.xyz.com",
"port": 443,
"method": "post",
"path": "/block",
"params": {},
"headers": {
"Host": "www.xyz.com",
"Content-Type": "application/json"
},
"body": {
"source": {
"WorkerId": "{{ctx.payload.aggregations.bucketAgg.buckets.key}}",
"Reason": "for test"
},
"lang": "mustache",
"options": {
"content_type": "application/json; charset=UTF-8"
}
}
}
}
}
Here you can see the relevant execution output of my Watcher:
(You can see the "key": "A27CQJNO9GMFTK" in the results and at the very end you can see the body of the webhook and the empty "WorkerID")
"result": {
"execution_time": "2019-08-04T20:13:03.163Z",
"execution_duration": 130,
"input": {
"type": "search",
"status": "success",
"payload": {
"_shards": {
"total": 2,
"failed": 0,
"successful": 2,
"skipped": 0
},
"hits": {
"hits": [],
"total": 1,
"max_score": null
},
"took": 2,
"timed_out": false,
"aggregations": {
"bucketAgg": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"doc_count": 1,
"metricAgg": {
"value": 0
},
"key": "A27CQJNO9GMFTK"
}
]
}
}
},
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"mobots_assignments*"
],
"rest_total_hits_as_int": true,
"body": {
"size": 0,
"query": {
"bool": {
"must": [
{
"match_phrase": {
"assignment_completed": {
"query": true
}
}
}
],
"filter": {
"range": {
"start_time": {
"gte": "2019-08-04T20:13:03.087Z||-75m",
"lte": "2019-08-04T20:13:03.087Z",
"format": "strict_date_optional_time||epoch_millis"
}
}
}
}
},
"aggs": {
"bucketAgg": {
"terms": {
"field": "workerId.keyword",
"size": 1,
"order": {
"metricAgg": "asc"
}
},
"aggs": {
"metricAgg": {
"min": {
"field": "f1score"
}
}
}
}
}
}
}
}
},
"condition": {
"type": "script",
"status": "success",
"met": true
},
"actions": [
{
"id": "mobots_webhook",
"type": "webhook",
"status": "failure",
"reason": "received [500] status code",
"webhook": {
"request": {
"host": "www.themobots.com",
"port": 443,
"scheme": "https",
"method": "post",
"path": "/create_worker_block",
"params": {
"p": ""
},
"headers": {
"Host": "www.themobots.com",
"Content-Type": "application/json"
},
"body": "{\"WorkerId\":\"\",\"Reason\":\"for test\"}"
},
"response": {
"status": 500,
},
.....
}
}
}
]
},
"messages": []
}
Can someone please tell me what I can do to hand over the "key": "A27CQJNO9GMFTK" to my Action body ?
Thank you!