Skip to content

feat: added sidecar to turn logs into metrics and forward remaining logs - #59

Open
CptSchnitz wants to merge 18 commits into
masterfrom
metrics-sidecar
Open

feat: added sidecar to turn logs into metrics and forward remaining logs#59
CptSchnitz wants to merge 18 commits into
masterfrom
metrics-sidecar

Conversation

@CptSchnitz

Copy link
Copy Markdown
Contributor

No description provided.

@CptSchnitz
CptSchnitz requested a review from shimoncohen August 6, 2026 10:19
shimoncohen

This comment was marked as duplicate.

Comment thread helm/config/nginx.conf
Comment on lines +55 to +56
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 }};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

CptSchnitz and others added 4 commits August 12, 2026 11:24
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants