Set relative time with timestamp

Is there a way to show the timestamp as a relative time to now?

So I'm currently monitoring some services and I'm only showing the latest data for each service. I'm currently displaying the timestamp in this format: April 16th 2019, 16:31:47.375.
I want to display it like: 60seconds ago or 2minutes ago. Is there a date format in Kibana that would let me do that. So [NOW-timestamp].

I was able to solve the problem once I knew that Scripted Fields existed so this is what I used to show how long ago the update was :

if(Math.round((new Date().getTime()-doc['@timestamp'].value)/1000)>7200){
   return Math.round((new Date().getTime()-doc['@timestamp'].value)/3600000) + " hours ago";
}else if(Math.round((new Date().getTime()-doc['@timestamp'].value)/1000)>3600){
   return Math.round((new Date().getTime()-doc['@timestamp'].value)/3600000) + " hour ago";
}else if(Math.round((new Date().getTime()-doc['@timestamp'].value)/1000)>120){
   return Math.round((new Date().getTime()-doc['@timestamp'].value)/60000) + " minutes ago";
} else if(Math.round((new Date().getTime()-doc['@timestamp'].value)/1000)>60){
   return Math.round((new Date().getTime()-doc['@timestamp'].value)/60000) + " minute ago";
}else {
   return Math.round((new Date().getTime()-doc['@timestamp'].value)/1000)  + " seconds ago";

Thanks for posting your solution.


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.