From 698a7ba707ba1e9102b2750fc1b837d1cc8f174f Mon Sep 17 00:00:00 2001 From: Piotr Pauksztelo Date: Fri, 29 Nov 2024 14:57:10 +0100 Subject: [PATCH] Fix timezone in log arrival and delta time --- logprep/abc/input.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/logprep/abc/input.py b/logprep/abc/input.py index 396d995c0..a3b3a6d2a 100644 --- a/logprep/abc/input.py +++ b/logprep/abc/input.py @@ -8,9 +8,10 @@ import zlib from abc import abstractmethod from copy import deepcopy -from functools import partial +from functools import partial, cached_property from hmac import HMAC from typing import Optional, Tuple +from zoneinfo import ZoneInfo from attrs import define, field, validators @@ -198,6 +199,11 @@ def _add_version_info(self): """Check and return if the version info should be added to the event.""" return bool(self._config.preprocessing.get("version_info_target_field")) + @cached_property + def _log_arrival_timestamp_timezone(self): + """Returns the timezone for log arrival timestamps""" + return ZoneInfo("UTC") + @property def _add_log_arrival_time_information(self): """Check and return if the log arrival time info should be added to the event.""" @@ -314,7 +320,7 @@ def _add_arrival_time_information_to_event(self, event: dict): new_field = { self._config.preprocessing.get( "log_arrival_time_target_field" - ): TimeParser.now().isoformat() + ): TimeParser.now(self._log_arrival_timestamp_timezone).isoformat() } add_fields_to(event, new_field)