send log timestamp parse errors to victorialogs
This commit is contained in:
@@ -60,18 +60,25 @@ Host: %s\
|
|||||||
(expect= (format-timestamp-rfc3339 "@4000000068e2f0d3257dc09b" 3)
|
(expect= (format-timestamp-rfc3339 "@4000000068e2f0d3257dc09b" 3)
|
||||||
"2025-10-05T22:26:54.628Z"))
|
"2025-10-05T22:26:54.628Z"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(fn process-line [line]
|
(fn process-line [line]
|
||||||
(let [(timestamp hostname service msg) (string.match line "(@%x+) (%g+) (%g+) (.+)$")]
|
(let [(timestamp hostname service msg) (string.match line "(@%x+) (%g+) (%g+) (.+)$")]
|
||||||
(->
|
(->
|
||||||
(string.format
|
(if timestamp
|
||||||
"{%q:%q,%q:%q,%q:%q,%q:%q}\n"
|
(string.format
|
||||||
:_time (format-timestamp-rfc3339 timestamp 3)
|
"{%q:%q,%q:%q,%q:%q,%q:%q}\n"
|
||||||
:service service
|
:_time (format-timestamp-rfc3339 timestamp 3)
|
||||||
:_msg msg
|
:service service
|
||||||
:host hostname)
|
:_msg msg
|
||||||
chunk)))
|
: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]
|
(fn writefd [fd body]
|
||||||
(case (ll.write fd body)
|
(case (ll.write fd body)
|
||||||
(bytes) (when (< bytes (# body)) (writefd fd (string.sub body bytes)))
|
(bytes) (when (< bytes (# body)) (writefd fd (string.sub body bytes)))
|
||||||
|
Reference in New Issue
Block a user