Hello,
I have a field containing seconds which I wish to convert to HH:mm:ss format in my visualization; I'm performing this using a scripted field of type date. This works fine, however if I specify a value of xx my conversion comes back with 1:00:xx. I assume the additional hour is due to my location which is currently under BST (UTC+1). So my question is how do I get the script to always return the value as UTC+0.
My script currently contains:
doc['doc.stats.OPERATOR_ASSISTS_AVERAGE_ANSWER_TIME'].value * 1000
Date fields must represent an exact point in time. They can't represent durations, which I think is what you're looking for. If you just want to display the number of seconds stored in stats.OPERATOR_ASSISTS_AVERAGE_ANSWER_TIME in a more human readable format, I would recommend using a field formatter.
Indirectly the field does represent an exact point in time albeit from 1970; so my question is more related to how do I get around seasonal time adjustments in general. I have the same issue with other true date fields.
My queries now work because the UK has moved to GMT but my dashboards will go awry again next summer.
The elastic server is always running in GMT so I assume the time adjustments are being performed by my browser and this is the issue I wish to work around. I was hoping that a more advanced painless script would address this for me.
/Pete
Kibana will do timezone conversion on date fields using your local tz by default. That's probably what is affecting your field. You can change this to a static timezone if you wish (see dateFormat:tzhere).
However, I still don't understand why you would want to use a date type field for this use case. Am I correct in understanding that stats.OPERATOR_ASSISTS_AVERAGE_ANSWER_TIME contains the number of seconds that it took to do something (a duration)? And you want to convert this number of seconds into a more human readable format? If so I'd highly recommend checking out the "Duration" numeric field formatter. Sorry if I'm just misunderstanding what you're trying to do.
I tried the number field formatter with type Duration but the responses are far to vague, 12 seconds comes out as "a few seconds" or 1 minute 30 as "around a couple of minutes". If I could use the field as it is intended i.e. a duration specified in seconds I would do. So the only solution I can see is to pretend it is a date so I can format it into HH:mm:ss .
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.