I have a Logstash pipeline where I build a timestamp string manually and then parse it into event.timestamp because we do not have a year value in the log message, there are just day and month in the file name.
Environment / Timezone setup
- Logstash runtime
TZ = UTC - Local business timezone
UTC+8 - I do not set timezone in the
datefilter, timezone conversion is intentionally handled only at the presentation layer (Kibana) @timestampis NOT modified anywhere in the pipeline and looks correct in Kibana.- The system ingests real-time data.
Pipeline code:
filter {
grok {
match => {
"message" => "^(?<seq_hour>\d{2})(?<seq_minute>\d{2})(?<seq_second>\d{2})"
}
}
mutate {
add_field => {
"log_timestamp_str" =>
"%{+YYYY}-%{file_month}-%{file_day} %{seq_hour}:%{seq_minute}:%{seq_second}"
}
}
date {
match => ["log_timestamp_str", "yyyy-MM-dd HH:mm:ss"]
target => "[event][timestamp]"
}
}
Observed behavior:
When the local time is 7 AM on 2026-01-01, file_month = 01, file_day = 01, time in log = 07:00:00.
I get @timestamp:
2025-12-31T23:00:00.456Z
Resulting event.timestamp becomes
2024-12-31T23:00:00.000Z
@timestamp itself appears correct in Kibana devtool and is not being modified.
Now, I understand this can be caused by Timezone issue because, the issue disappears when the local time comes to 2026-01-01 09:00:00 (out of 8 hour boundary). Just not sure why the year becomes 2024 in this case.
My Questions:
- Is
%{+YYYY}in Logstash always derived from@timestampat the time the mutate filter runs? - This is confusing because, as far as I understand, 2025-12-31 (calendar year) should only map to ISO week-year 2025 or 2026. Why can an ended ISO week-year of 2025 be matched to 2024 (Please help me correct if I am wrong about this)?
Any clarification from Elastic engineers or references to official documentation would be much appreciated.