Add Lua functions to reassemble partial cri-o logs
This commit is contained in:
parent
48045d7afc
commit
d04e7fa0f1
@ -234,6 +234,12 @@ fluent-bit:
|
||||
DB.Sync Normal
|
||||
|
||||
filters: |
|
||||
[FILTER]
|
||||
Name lua
|
||||
Match kube.*
|
||||
script /fluent-bit/etc/functions.lua
|
||||
call reassemble_cri_logs
|
||||
|
||||
[FILTER]
|
||||
Name kubernetes
|
||||
Match kube.*
|
||||
@ -290,6 +296,25 @@ fluent-bit:
|
||||
end
|
||||
end
|
||||
|
||||
local reassemble_state = {}
|
||||
|
||||
function reassemble_cri_logs(tag, timestamp, record)
|
||||
-- IMPORTANT: reassemble_key must be unique for each parser stream
|
||||
-- otherwise entries from different sources will get mixed up.
|
||||
-- Either make sure that your parser tags satisfy this or construct
|
||||
-- reassemble_key some other way
|
||||
local reassemble_key = tag
|
||||
-- if partial line, accumulate
|
||||
if record.logtag == 'P' then
|
||||
reassemble_state[reassemble_key] = reassemble_state[reassemble_key] or "" .. record.message
|
||||
return -1, 0, 0
|
||||
end
|
||||
-- otherwise it's a full line, concatenate with accumulated partial lines if any
|
||||
record.message = reassemble_state[reassemble_key] or "" .. record.message
|
||||
reassemble_state[reassemble_key] = nil
|
||||
return 1, timestamp, record
|
||||
end
|
||||
|
||||
serviceMonitor:
|
||||
enabled: true
|
||||
namespace: monitoring
|
||||
|
Loading…
Reference in New Issue
Block a user