ES 6.0 - Scripted Field HourOfDay with Timezone - error

Hello,

First Post Here, I will try to do my best to make a clear presentation.

I recently upgraded ELK on my UAT node from 5.6 to 6.0
OS : 2012r2 ; single node.
ELK : 6.0.0
Java : 1.8.0_151

I was running a painless scripted field pretty well on 5.6.0 to deduce HourOfDay, as follow :
Name : HourOfDay
Script : LocalDateTime.ofInstant(Instant.ofEpochMilli(doc['@timestamp'].value),ZoneId.of('Europe/Paris')).getHour()

I used this script because of the Timezone I'm using : Europe/Paris ; it's working pretty well on a 5.6 ELK, I'm getting a consistent value for HourOfDay.

Q1 : This scripted field doesn't work anymore on ELK 6.0 ; any clue ?
-Error when opening Kibana : Courier Fetch: 5 of 330 shards failed.
-Error From ES logs : https://pastebin.com/ST3BUP29

Deleting the scripted field dos not pop the error... I tried the following workaround :

Q2 : Using the scripted field with : doc["@timestamp"].date.hourOfDay does not work as intended.
Only The UTC HourOfDay is shown, and my Timezone is never applied when showing the value.

Regards
Luc

In 6.0, for a date field, .value is a ReadableDateTime. In the past this was a long. So you will want to call .value.millis and the rest of your code should continue to work.

Hi Ryan,

Thank you for your suggestion, which is working pretty well :wink:

For others that would have the same issue , I updated the scripted field as suggested :

LocalDateTime.ofInstant(Instant.ofEpochMilli(doc['@timestamp'].value.millis),ZoneId.of('Europe/Paris')).getHour()

Merci beaucoup, Have a nice week-end :wink:
Regards
Luc

3 Likes

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