Uh oh!
There was an error while loading. Please reload this page.
feat: added sidecar to turn logs into metrics and forward remaining logs - #59
feat: added sidecar to turn logs into metrics and forward remaining logs#59CptSchnitz wants to merge 18 commits into
Conversation
…nt and resource limits - step 1
638b63b to
ce005a9Compare
This comment was marked as duplicate.
This comment was marked as duplicate.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| access_log /var/log/nginx/access.log {{ if .Values.fluentbit.enabled }}{{ if .Values.fluentbit.accessLog.stdoutReadable }}readable{{ else }}main{{ end }}; | ||
| access_log syslog:server=127.0.0.1:{{ .Values.fluentbit.accessLog.syslogPort }} main{{ else }}main{{ end }}; |
There was a problem hiding this comment.
The nested if/else here is hard to read, suggested two options.
Option 1 — split the whole block by the outer condition. Each rendered result is visible verbatim; no directive value straddles a template boundary.
{{- if .Values.fluentbit.enabled }}
access_log /var/log/nginx/access.log {{ .Values.fluentbit.accessLog.stdoutReadable | ternary "readable" "main" }};
access_log syslog:server=127.0.0.1:{{ .Values.fluentbit.accessLog.syslogPort }} main;
{{- else }}
access_log /var/log/nginx/access.log main;
{{- end }}
Cost: the file access_log ... main; literal is duplicated across both branches — a 1-line dupe in exchange for a readable conditional.
Option 2 — name the format, keep one file directive. Zero duplication; the format decision is a named variable up top instead of inline nesting.
{{- $stdoutFormat := "main" }}
{{- if and .Values.fluentbit.enabled .Values.fluentbit.accessLog.stdoutReadable }}
{{- $stdoutFormat = "readable" }}
{{- end }}
access_log /var/log/nginx/access.log {{ $stdoutFormat }};
{{- if .Values.fluentbit.enabled }}
access_log syslog:server=127.0.0.1:{{ .Values.fluentbit.accessLog.syslogPort }} main;
{{- end }}
Both read top-to-bottom without straddling template boundaries. Option 1 is a touch clearer at the cost of one duplicated literal; Option 2 avoids the dupe with one extra variable.
fluentbit.lua.call becomes fluentbit.lua.calls.allRecords and fluentbit.lua.calls.forwardedOnly, both empty by default. Each non-empty call renders its own lua filter against the same mounted script, so a field the script computes at allRecords — which runs after the exclude grep but ahead of log_to_metrics and the forwarding grep — can be an add_label or value_field accessor in accessLog.metrics.filters. forwardedOnly keeps the hook's existing position, where decoration-only logic pays for Lua on the shipped subset only. Enabling the hook without naming an entry point mounts a script nothing calls, so it fails the render instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
fluentbit.lua.configMap.name/key mount a ConfigMap the operator maintains outside the release at the same /fluent-bit/scripts/custom.lua the filters name, so nothing downstream of the mount changes. It is an alternative to the inline fluentbit.lua.script, not an addition: nginx.fluentbit.luaSource decides which of the two is in play — and fails the render on both, neither, or a named ConfigMap without a key — so the ConfigMap key, the volume and the mount all branch on one answer. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
No description provided.