How to get human readable duration from milliseconds in Elasticsearch Painless language?

168 Views Asked by At

This doesn't work, just giving a "compile error" message in the watcher simulator.

1

There are 1 best solutions below

0
On

It looks like the AWS Elasticsearch disables regexes by default. The (so far untested, but compiles) solution avoiding regexes is Duration.ofMillis(ctx.payload._source.computed.duration).toString().substring(2).replace("H", "h ").replace("M", "m ").replace("S", "s").trim().