From 29fbb5461d034c4c59b88cbe04937b04ecad18e0 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Wed, 8 Oct 2025 19:43:57 +0100 Subject: [PATCH] send log timestamp parse errors to victorialogs --- pkgs/logshippers/victorialogsend.fnl | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/pkgs/logshippers/victorialogsend.fnl b/pkgs/logshippers/victorialogsend.fnl index 0f989e6..fb5b35c 100644 --- a/pkgs/logshippers/victorialogsend.fnl +++ b/pkgs/logshippers/victorialogsend.fnl @@ -60,18 +60,25 @@ Host: %s\ (expect= (format-timestamp-rfc3339 "@4000000068e2f0d3257dc09b" 3) "2025-10-05T22:26:54.628Z")) - - (fn process-line [line] (let [(timestamp hostname service msg) (string.match line "(@%x+) (%g+) (%g+) (.+)$")] (-> - (string.format - "{%q:%q,%q:%q,%q:%q,%q:%q}\n" - :_time (format-timestamp-rfc3339 timestamp 3) - :service service - :_msg msg - :host hostname) - chunk))) + (if timestamp + (string.format + "{%q:%q,%q:%q,%q:%q,%q:%q}\n" + :_time (format-timestamp-rfc3339 timestamp 3) + :service service + :_msg msg + :host hostname) + (string.format + "{%q:%q,%q:%q,%q:%q,%q:%q}\n" + :_time (os.date "!%FT%TZ") + :service "ERROR" + :_msg (string.format "can't parse log %q" msg) + :host hostname)) + chunk) + )) + (fn writefd [fd body] (case (ll.write fd body) (bytes) (when (< bytes (# body)) (writefd fd (string.sub body bytes)))