Kibana - Scripted Field TimeZone in Month

Hi, I'm trying use scripted fields to get day, month and year of a date field but get some trouble over month field. I have the following scenario:

First Test:

Timezone of Server : UTC-3 (America/Fortaleza)
Timezone of Kibana Advanced Settings: UTC (Standard)

Time Day Month ID
01/11/2019 00:03:00 1 November 21769
31/10/2019 23:58:00 31 October 21768

But expected
Time Day Month ID
31/10/2019 21:03:00 31 October 21769
31/10/2019 20:58:00 31 October 21768

Second Test:

Timezone of Server : UTC-3 (America/Fortaleza)
Timezone of Kibana Advanced Settings: UTC-3 (America/Fortaleza)

Time Day Month ID
31/10/2019 21:03:00 1 November 21769
31/10/2019 20:58:00 31 October 21768

But expected
Time Day Month ID
31/10/2019 21:03:00 31 October 21769
31/10/2019 20:58:00 31 October 21768

Third Test:

Timezone of Server : UTC-3 (America/Fortaleza)
Timezone of Kibana Advanced Settings: UTC-3 (America/Fortaleza)
Scripted Field in Index Patterns
def day = LocalDateTime.ofInstant(Instant.ofEpochMilli(doc['datetime'].value.millis),ZoneId.of('UTC-3')).dayOfMonth; return day;

Time Day Month ID
31/10/2019 21:03:00 31 November 21769
31/10/2019 20:58:00 31 October 21768

But expected
Time Day Month ID
31/10/2019 21:03:00 31 October 21769
31/10/2019 20:58:00 31 October 21768

So my ask is how define timeZone in scripted field of month or other solution option?

I use this scripted field for month

def month = doc['datetime'].value.monthOfYear; def months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ]; return months[month-1];

I'm trying apply this scripted field but nothing changes

int year = doc['data'].value.year;
int month = doc['data'].value.monthOfYear;
int day = doc['data'].value.dayOfMonth;
int hour = doc['data'].value.hourOfDay;
int minutes = doc['data'].value.minuteOfHour;
int seconds = doc['data'].value.secondOfMinute;
int nanos = 0;
ZonedDateTime zdt = ZonedDateTime.of(year, month, day, hour, minutes, seconds, nanos, ZoneId.of('UTC-3'));
int tzyear = zdt.getYear();
int tzmonth = zdt.getMonthValue();
int tzday = zdt.getDayOfMonth();
int tzhour = zdt.getHour();
int tzminutes = zdt.getMinute();
int tzseconds = zdt.getSecond();
int tznanos = zdt.getNano();
def months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ]; return months[tzmonth-1];

int year = doc['data'].value.year;
int month = doc['data'].value.monthOfYear;
int day = doc['data'].value.dayOfMonth;
int hour = doc['data'].value.hourOfDay;
int minutes = doc['data'].value.minuteOfHour;
int seconds = doc['data'].value.secondOfMinute;
int nanos = 0;
ZonedDateTime zdt = ZonedDateTime.of(year, month, day, hour, minutes, seconds, nanos, ZoneId.of('UTC'));

ZonedDateTime updatedZdt = zdt.minusHours(3);

int tzyear = updatedZdt.getYear();
int tzmonth = updatedZdt.getMonthValue();
int tzday = updatedZdt.getDayOfMonth();
int tzhour = updatedZdt.getHour();
int tzminutes = updatedZdt.getMinute();
int tzseconds = updatedZdt.getSecond();
int tznanos = updatedZdt.getNano();
def months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ]; return months[tzmonth-1];

I don't know but this scripted field works

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