Hi,
I am playing with Watcher to setup an alert for certain threshold. If condition is met, then I want to send a message via Slack with the aggregated value. Everything is working perfectly, except the number looks like 0.9823284906645616. I would like to format this number with only 2 decimal numbers. I am not sure how to achieve that or even if it is possible. Can I do this in the action side {{ctx.payload.results.0.value}}? Or do I need to make this in the transformation piece:
"transform" : {
"script" : {
"source" : "HashMap result = new HashMap(); ArrayList arr = ctx.payload.aggregations.bucketAgg.buckets; ArrayList filteredHits = new ArrayList(); for (int i = 0; i < arr.length; i++) { HashMap filteredHit = new HashMap(); filteredHit.key = arr[i].key; filteredHit.value = arr[i]['metricAgg'].value; if (filteredHit.value < params.threshold) { filteredHits.add(filteredHit); } } result.results = filteredHits; return result;",
"lang" : "painless",
"params" : {
"threshold" : 1.5
}
}
}
Thanks,
Cesar Lino