Skip to content

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

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

feat: added sidecar to turn logs into metrics and forward remaining logs#59
CptSchnitz wants to merge 14 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.

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