Hey,
take a look at this example
return ctx.payload.aggregations.uuid.buckets.stream().allMatch(b -> b.age.value > 5)
this would check for all the age values being greater than five. You can do more complex checks of course. Maybe also check the alerting examples in the examples repo
Hope this helps as a start.
--Alex