Unable to return multiple returns from transform

alerting

(prasad) #1

I am new to writing watchers, could you please help on below usecase

Trying to write a watcher which has requirement to have two table in the body of e-mail. Attachment contains table information.

I am unable to return multiple values from "transform" and iterate in Body of the send_email action.

Here is is my watcher transform,

"transform": {
"chain": [{
"script": "return ctx.payload.global_data.aggregations.group_by_exception.buckets.stream().filter( dr -> { ((dr.range.buckets.earlier.total_count.value < 100 && ((dr.range.buckets.latest.total_count.value-dr.range.buckets.earlier.total_count.value > 50) || (dr.range.buckets.earlier.total_count.value-dr.range.buckets.latest.total_count.value > 50))) || (dr.range.buckets.earlier.total_count.value > 100 && ((dr.range.buckets.latest.total_count.value-dr.range.buckets.earlier.total_count.value > 50) || (dr.range.buckets.earlier.total_count.value-dr.range.buckets.latest.total_count.value > 50))))}).map(i ->['app_name':i.key,'earlier_count':(int)i.range.buckets.earlier.total_count.value,'latest_count':(int)i.range.buckets.latest.total_count.value, 'gpercentage':((float)((i.range.buckets.latest.total_count.value - i.range.buckets.earlier.total_count.value)/(float)(i.range.buckets.earlier.total_count.value))*100)]).collect(Collectors.toList());"
}, {
"script": "return ctx.payload.app_wise_data.aggregations.group_by_app.buckets.stream().map(app ->['App': app.key,'Brands': app.by_brand.buckets.stream().map(bmap ->['brand': bmap.key,'DataCenters':bmap.by_dc.buckets.stream().filter(dm -> { ((dm.range.buckets.earlier.total_count.value < 100 && ((dm.range.buckets.latest.total_count.value-dm.range.buckets.earlier.total_count.value > 50) || (dm.range.buckets.earlier.total_count.value-dm.range.buckets.latest.total_count.value > 50))) || (dm.range.buckets.earlier.total_count.value > 100 && ((dm.range.buckets.latest.total_count.value-dm.range.buckets.earlier.total_count.value > 50) || (dm.range.buckets.earlier.total_count.value-dm.range.buckets.latest.total_count.value > 500))))}).map(dcmap -> ['dc':dcmap.key,'earlier':(int)dcmap.range.buckets.earlier.total_count.value,'latest':(int)dcmap.range.buckets.latest.total_count.value,'percentage':(int)(((dcmap.range.buckets.latest.total_count.value - dcmap.range.buckets.earlier.total_count.value)/(dcmap.range.buckets.earlier.total_count.value))*100),'up':(((dcmap.range.buckets.latest.total_count.value - dcmap.range.buckets.earlier.total_count.value)/(dcmap.range.buckets.earlier.total_count.value))*100) > 0.0]).collect(Collectors.toList())]).collect(Collectors.toList())]).collect(Collectors.toList());"
}]
}


(Alexander Reelsen) #2

you need to use a script transform, where you do both table creations in a single script.


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.