I've been trying to develop a script that can be used for a number different watcher tasks. I came across this this post and it was quite helpful in showing me how to map the output of two aggregations. However, I don't understand painless or Java well enough to get the output of this scipt to print prettier. Can someone point me in the right direction?
{
"script": {
"source": "return [ 'hosts' : ctx.payload.aggregations.hosts.buckets.stream().map(b -> [b.key: b.values.value]).collect(Collectors.toList()) ]",
"lang": "painless"
}
}
Existing output (sample):
{0={dev01.foo.bar=0.892}, 1={dev02.foo.bar=0.8310000000000001})
Preferred output (something with line breaks and less array postion designations):
dev01.foo.bar=0.892
dev02.foo.bar=0.8310000000000001
Much appreciation in advance, all.
-Z