JSON Input: Converting Minutes to Minutes and Seconds

Hi

I'm using Kibana 5.5.1

I want to convert serveAvg (currently in seconds) to Minutes and Seconds.
Currently i managed to convert to Minutes only using below script

{
"script": {
"inline1": "doc['serveAvg'].value / 60",
"lang": "painless"
}

for example serveAve = 217.671

when convert using above script it gave me 3.628

i want the result to be 3 minutes and 38 seconds. Can anyone please help me to solve this prob. Tq

image

I think you could put this script in the JSON Input field, but I found it a little easier to create a Scripted Field on my index to do it. And then you can use the scripted field in many visualizations without having to replicate that JSON Input code.

In the screenshot below, I used some number type field metricset.rtt and used it in a scripted field of type date.
I set the Format to Date, and the pattern to minutes:seconds mm:ss. I guess it assumed the value was milliseconds so I multiplied by 1000. I named my scripted field metricset.time

Now in Discover I can add both the original metricset.rtt and my scripted field metricset.time so I can check that the calculation is working as expected.

You could easily change it to HH:mm:ss or create another scripted field with that formatting.

Regards,
Lee

4 Likes

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