Hi
I need help for new scripted field for this case:
started_at: 2017-04-01 07:41:25
ended_at: 2017-05-01 10:14:34
output: 26:33:09
I am using Kibana 6.4.2
Hi
I need help for new scripted field for this case:
started_at: 2017-04-01 07:41:25
ended_at: 2017-05-01 10:14:34
output: 26:33:09
I am using Kibana 6.4.2
It's going to be faster to precompute this value and store it in the raw document, but if you need to do so using a scripted field, the following painless script will get you the difference in "day:hour:second" format:
def diffInMs = doc['ended_at'].value.getMillis() - doc['started_at'].value.getMillis();
def duration = Duration.ofMillis(diffInMs);
def hours = duration.toHours();
def minutes = duration.minusHours(hours).toMinutes();
def seconds = duration.minusHours(hours).minusMinutes(minutes).getSeconds();
def str = hours + ':' + minutes + ':' + seconds;
return str;
Thanks Brandon
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
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.