I need to calculate duration using 2 date fields in watcher API. I tried using painless script and to test using scripted field. But it is errors out stating invalid syntax. What is missing in below ?
Firstly, I get an exception since newlines are not allowed in the JSON source. Put it all on one line.
I can't try this in Watcher right now. But here's something that works against the Painless Execute API as if I were running it in a function_score query. I'm just using the context because it's the only one that supports reading from a doc and returning a number - you're trying to return 0 or number of milliseconds. You may need to adjust slightly for Watcher!
Do these in the Kibana Dev Console to try for yourself:
changed the conditional to check both date fields exist and that they're not empty (the recommended way is via .size() != 0). I think this is what you were trying to do but correct me if wrong.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.