Hi,
I'm facing a problem from a while : returning multiple values filtered from a sum aggregation
.
I want to detect if the sum of my cs_bytes
exceed a particular threshold
• this condition works :
"condition" : { "script" : { "inline": "for(int i = 0; i<10;i++){if (ctx.payload.aggregations.2.buckets[i].1.value > 100000000)return true}" }
where 2 is a bucket aggregation by terms (username) and 1 is my sum aggregation.
My for loop doesn't satisfy my excpectations : it cross the index and if one condition is met the whole condition is verified.
From there I want to extract the values ( values of i
in my case where the condition is completed) of my condition and use them in my email alert.
I tried severals things to fix this issue :
• filter my sum aggregation before the condition in order to come up with the result , unfortunatly sum aggs doesn't allow sub-aggregations.
• Filter my aggs with a range aggs for the field cs_bytes
but this returns wrong data
The best way will be to be able to apply a range agg on my sum aggs...
To sum up my problem : I would like to find a proper way to extract the indices where my condition is verified
-Chris