diff --git a/logprep/abc/input.py b/logprep/abc/input.py index 12f1a5143..ed9e1223a 100644 --- a/logprep/abc/input.py +++ b/logprep/abc/input.py @@ -339,8 +339,8 @@ def _add_arrival_time_information_to_event(self, event: dict): def _write_full_event_to_target_field(self, event_dict: dict, raw_event: bytearray): target = self._config.preprocessing.get("add_full_event_to_target_field") if raw_event is None: - raw_event = json.dumps(event_dict) - complete_event = json.dumps(raw_event) + raw_event = self._encoder.encode(event_dict) + complete_event = json.dumps(raw_event.decode("utf-8")) event_dict.clear() add_fields_to(event_dict, fields={target: complete_event}, overwrite_target=True) diff --git a/tests/unit/connector/base.py b/tests/unit/connector/base.py index c8b4fa0c4..dd4d91ec8 100644 --- a/tests/unit/connector/base.py +++ b/tests/unit/connector/base.py @@ -453,7 +453,7 @@ def test_add_full_event_to_target_field(self): test_event = {"any": "content"} connector._get_event = mock.MagicMock(return_value=(test_event, None)) result = connector.get_next(0.01) - expected = {"event": {"original": '{"any":"content"}'}} + expected = {"event": {"original": '"{\\"any\\":\\"content\\"}"'}} assert result == expected, f"{expected} is not the same as {result}" def test_pipeline_preprocessing_does_not_add_timestamp_delta_if_configured_but_log_arrival_timestamp_not(