Kibana-1 hour gap


I had implemented the stack and now I tried to improve my dashboard.
I created a script field to get the day of week. It was very easy : doc['@timestamp'].date.dayOfWeek

But when I create a visualize with @timestamp and this script field, I had a 1-hour gap.
For instance
14/03/2018 22:50:00 -> 3 (wednesday) -> good
14/03/2018 23:30:00 -> 3 (wednesday) -> good
15/03/2018 00:55:00 -> 3 (wednesday) -> incorrect... I'd like to have 4 (thursday)
15/03/2018 01:05:00 -> 4 (thursday) -> good

How can I fix this problem ? Maybe there is a workaround like : [doc['@timestamp'] - 1h].date.dayOfWeek ? For sure, the syntax is not correct. But if you could tell me how I can that, it would be fantastic.

Thank you for helping.

Seems like maybe the data is in a different time zone from you (1 hour offset). Kibana displays dates in the time zone of the browser, not the data, so you would see results like that if you are viewing the data in a timezone offset by 1 hour. If that is the case, then your proposed fix would work for you, but not for anyone viewing the data in a different time zone.

Thanks for your reply.
indeed, it seems to me a good reason. I'd like to try my fix. But I don't know the syntax.

What is the good syntax for : [doc['@timestamp'] - 1h].date.dayOfWeek ?

This should work:

Instant instant = Instant.ofEpochMilli(doc['@timestamp'].value.getMillis());
instant = instant.minus(1, ChronoUnit.HOURS);
return instant.atOffset(ZoneOffset.UTC).get(ChronoField.DAY_OF_WEEK);

Be sure to set the type and format of the field to number. You will need to substitute the correct time zone for the data for ZoneOffset.UTC.

Yeah, it works very well :-). Thank you Bill_McConaghy !

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