first commit
This commit is contained in:
104
templates/fluent-bit/configmap-luascript.yaml
Normal file
104
templates/fluent-bit/configmap-luascript.yaml
Normal file
@@ -0,0 +1,104 @@
|
||||
{{- if and .Values.fluentBit.enabled (eq .Values.fluentBit.kind "DaemonSet") -}}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ template "fluent-bit.appName" . }}-luascript
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "fluent-bit.labels" . | nindent 4 }}
|
||||
data:
|
||||
create_runtime_Directories.lua: |
|
||||
local function resolve_folder_path(folder_path, file_name)
|
||||
if file_name == "inbound" then
|
||||
folder_path = folder_path .. "/" .. file_name
|
||||
end
|
||||
return folder_path
|
||||
end
|
||||
|
||||
local function write_log(folder_path, file_name, log_content)
|
||||
local file_path = folder_path .. "/" .. file_name .. ".log"
|
||||
local file, err = io.open(file_path, "a")
|
||||
if file then
|
||||
-- Write log content to the file
|
||||
file:write(log_content .. "\n")
|
||||
file:close()
|
||||
print(string.format("Successfully wrote log to file: %s", file_path))
|
||||
else
|
||||
print(string.format("Failed to open file: %s, error: %s", file_path, err))
|
||||
end
|
||||
end
|
||||
|
||||
local function handle_txn_logs(tag, timestamp, record, file_name)
|
||||
local orgId = record["orgSchema"]
|
||||
local modeId = record["modeId"]
|
||||
local transactionId = record["transactionId"]
|
||||
local log_content = record["log"]
|
||||
|
||||
if not orgId or not modeId then
|
||||
print("Skipping directory creation: orgId or modeId is nil")
|
||||
return 1, timestamp, record
|
||||
end
|
||||
|
||||
local efs_root = os.getenv("efs_root")
|
||||
print(string.format("efs root value...: %s", efs_root))
|
||||
local folder_path = string.format("%s/logs/%s/%s/transaction/%s", efs_root, orgId, modeId, transactionId)
|
||||
folder_path = resolve_folder_path(folder_path, file_name)
|
||||
|
||||
local success, exit_type, exit_code = os.execute("mkdir -p " .. folder_path)
|
||||
|
||||
if success then
|
||||
write_log(folder_path, file_name, log_content)
|
||||
else
|
||||
print(string.format("Failed to create folder: %s", folder_path))
|
||||
end
|
||||
return 1, timestamp, record
|
||||
end
|
||||
|
||||
local function handle_app_logs(tag, timestamp, record, dir_name, file_name)
|
||||
local log_content = record["log"]
|
||||
local pod_name = record["kubernetes"]["pod_name"]
|
||||
print(string.format("pod name...: %s", pod_name))
|
||||
|
||||
local efs_root = os.getenv("efs_root")
|
||||
print(string.format("efs root value...: %s", efs_root))
|
||||
local folder_path = string.format("%s/logs/%s/%s", efs_root, dir_name, pod_name)
|
||||
folder_path = resolve_folder_path(folder_path, file_name)
|
||||
|
||||
write_log(folder_path, file_name, log_content)
|
||||
|
||||
return 1, timestamp, record
|
||||
end
|
||||
|
||||
function handle_orchestrator_txn_logs(tag, timestamp, record)
|
||||
return handle_txn_logs(tag, timestamp, record, "ir")
|
||||
end
|
||||
|
||||
function handle_inbound_txn_logs(tag, timestamp, record)
|
||||
return handle_txn_logs(tag, timestamp, record, "inbound")
|
||||
end
|
||||
|
||||
function handle_fusion_operator_logs(tag, timestamp, record)
|
||||
return handle_app_logs(tag, timestamp, record, "fusion-operator", "fusion-operator")
|
||||
end
|
||||
|
||||
function handle_envoy_logs(tag, timestamp, record)
|
||||
return handle_app_logs(tag, timestamp, record, "envoy", "envoy")
|
||||
end
|
||||
|
||||
function handle_orchestrator_logs(tag, timestamp, record)
|
||||
return handle_app_logs(tag, timestamp, record, "ir", "orchestrator")
|
||||
end
|
||||
|
||||
function handle_inbound_logs(tag, timestamp, record)
|
||||
return handle_app_logs(tag, timestamp, record, "inbound", "inbound")
|
||||
end
|
||||
|
||||
function handle_pep_server_logs(tag, timestamp, record)
|
||||
return handle_app_logs(tag, timestamp, record, "pep-server", "pep-server")
|
||||
end
|
||||
|
||||
function handle_sink_agent_logs(tag, timestamp, record)
|
||||
return handle_app_logs(tag, timestamp, record, "sinkagent", "sinkagent")
|
||||
end
|
||||
|
||||
{{- end }}
|
||||
Reference in New Issue
Block a user