New Lua function to nest entries into kube.<namespace>.*
This commit is contained in:
parent
cb3c6a93ba
commit
a951e7d9a0
@ -2,7 +2,7 @@ apiVersion: v2
|
||||
name: kubezero-logging
|
||||
description: KubeZero Umbrella Chart for complete EFK stack
|
||||
type: application
|
||||
version: 0.4.0
|
||||
version: 0.4.1
|
||||
appVersion: 1.2.1
|
||||
home: https://kubezero.com
|
||||
icon: https://cdn.zero-downtime.net/assets/kubezero/logo-small-64.png
|
||||
|
@ -238,6 +238,12 @@ fluent-bit:
|
||||
Emitter_Name kube_tag_rewriter
|
||||
Rule logtag F kube.$kubernetes['namespace_name'].$kubernetes['container_name'] false
|
||||
|
||||
[FILTER]
|
||||
Name lua
|
||||
Match kube.*
|
||||
script /fluent-bit/etc/functions.lua
|
||||
call nest_k8s_ns
|
||||
`
|
||||
service: |
|
||||
[SERVICE]
|
||||
Flush 1
|
||||
@ -253,22 +259,32 @@ fluent-bit:
|
||||
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.log
|
||||
return -1, 0, 0
|
||||
end
|
||||
-- otherwise it's a full line, concatenate with accumulated partial lines if any
|
||||
record.log = reassemble_state[reassemble_key] or "" .. (record.log or "")
|
||||
reassemble_state[reassemble_key] = nil
|
||||
return 1, timestamp, record
|
||||
end
|
||||
|
||||
function nest_k8s_ns(tag, timestamp, record)
|
||||
if not record['kubernetes']['namespace_name'] then
|
||||
return 0, 0, 0
|
||||
end
|
||||
new_record = {}
|
||||
for key, val in pairs(record) do
|
||||
if key == 'kube' then
|
||||
new_record[key] = {}
|
||||
new_record[key][record['kubernetes']['namespace_name']] = record[key]
|
||||
else
|
||||
new_record[key] = record[key]
|
||||
end
|
||||
end
|
||||
return 1, timestamp, new_record
|
||||
end
|
||||
|
||||
serviceMonitor:
|
||||
enabled: true
|
||||
namespace: monitoring
|
||||
|
Loading…
Reference in New Issue
Block a user