Hi all
I have a problem with inline script for condition in a watch.
The payload response is like the one below, and I have to calculate the condition on the ratio
KO.dco_count/hits.total
I wrote
"condition" : {
"script" : {
"inline" : "return ctx.payload.aggregations.2.buckets.KO.doc_count/ctx.payload.hits.total > threshold",
"params" : {
"threshold" : 0.1
}
}
}
but it gives me error on "ctx.payload.aggregations.2.buckets.KO.doc_count"
payload
{
"responses": [{
"took": 34,
"timed_out": false,
"_shards": {
"total": 20,
"successful": 20,
"failed": 0
},
"hits": {
"total": 5434,
"max_score": 0.0,
"hits": []
},
"aggregations": {
"2": {
"buckets": {
"OK": {
"doc_count": 5343
},
"KO": {
"doc_count": 91
}
}
}
}
}]
}