Skip to content

Instantly share code, notes, and snippets.

@BarthV
Last active July 19, 2020 07:53
Show Gist options
  • Save BarthV/17521ff8cc5c5b3b704c9e2f491c7e60 to your computer and use it in GitHub Desktop.
Save BarthV/17521ff8cc5c5b3b704c9e2f491c7e60 to your computer and use it in GitHub Desktop.
# ConfigMap here with both files
#################################
---
apiVersion: v1
kind: ConfigMap
metadata:
name: fluentbit-dedot-lua
data:
dedot.conf: |2
[FILTER]
Name lua
Match kube.*
script /dedot-lua/dedot.lua
call dedot
dedot.lua: |2
function dedot(tag, timestamp, record)
if record["kubernetes"] == nil then
return 0, 0, 0
end
dedot_keys(record["kubernetes"]["annotations"])
dedot_keys(record["kubernetes"]["labels"])
return 1, timestamp, record
end
function dedot_keys(map)
if map == nil then
return
end
local new_map = {}
local changed_keys = {}
for k, v in pairs(map) do
local deslashed = string.gsub(k, "%/", "_")
local dedotted = string.gsub(deslashed, "%.", "_")
if dedotted ~= k then
new_map[dedotted] = v
changed_keys[k] = true
end
end
for k in pairs(changed_keys) do
map[k] = nil
end
for k, v in pairs(new_map) do
map[k] = v
end
end
# Important fluent-bit chart values not to miss
################################################
extraVolumes:
- name: dedot-lua
configMap:
name: fluentbit-dedot-lua
extraVolumeMounts:
- name: dedot-lua
mountPath: /dedot-lua
rawConfig: |-
@INCLUDE fluent-bit-service.conf
@INCLUDE fluent-bit-input.conf
@INCLUDE fluent-bit-filter.conf
@INCLUDE /dedot-lua/dedot.conf # this one was added
@INCLUDE fluent-bit-output.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment