Skip to content

metrics-apiserver zap logger not respected #791

Description

@drornir

The chart doesn't have conditionals on log arguments on metrics-apiserver, meaning the deprecated behavior is the only one that is respected.

The args are here

This is what we have now:

          args:
          - --logtostderr=true
          - --stderrthreshold={{ .Values.logging.metricServer.stderrthreshold }}
          - --v={{ .Values.logging.metricServer.level }}
          - --zap-log-level={{ .Values.logging.metricServer.zapLevel }}
          - --zap-encoder={{ .Values.logging.metricServer.zapEncoder }}
          - --zap-time-encoding={{ .Values.logging.metricServer.zapTimeEncoding }}

But there needs to be some logic to not pass --v and the other deprecated flags. Something like

          args:
          {{- if not .Values.logging.metricServer.useZapLogger }}
          - --logtostderr=true
          - --stderrthreshold={{ .Values.logging.metricServer.stderrthreshold }}
          - --v={{ .Values.logging.metricServer.level }}
          {{- end }}
          - --zap-log-level={{ .Values.logging.metricServer.zapLevel }}
          - --zap-encoder={{ .Values.logging.metricServer.zapEncoder }}
          - --zap-time-encoding={{ .Values.logging.metricServer.zapTimeEncoding }}

Expected Behavior

Logs are in json format when setting these values:

logging:
  metricServer:
    zapLevel: info
    zapEncoder: json

for example after manually editing the deployment to remove the depracated flags:

{"level":"info","ts":"2025-11-25T13:26:54Z","logger":"keda_metrics_adapter","msg":"KEDA Version: 2.18.1"}
{"level":"info","ts":"2025-11-25T13:26:54Z","logger":"keda_metrics_adapter","msg":"Git Commit: 3f590ba6027a67b2d6f79ece605061f6d201c54b"}
{"level":"info","ts":"2025-11-25T13:26:54Z","logger":"keda_metrics_adapter","msg":"Go Version: go1.24.7"}
{"level":"info","ts":"2025-11-25T13:26:54Z","logger":"keda_metrics_adapter","msg":"Go OS/Arch: linux/amd64"}
...
# There are still logs not in json format but I think this is an upstream problem, not a chart problem
I1125 13:26:54.874926       1 secure_serving.go:211] Serving securely on [::]:6443
...

Actual Behavior

Unstructured logs, for example:

2025-11-25T13:50:57.030Z    INFO    keda_metrics_adapter    KEDA Version: 2.18.1
2025-11-25T13:50:57.030Z    INFO    keda_metrics_adapter    Git Commit: 3f590ba6027a67b2d6f79ece605061f6d201c54b
2025-11-25T13:50:57.030Z    INFO    keda_metrics_adapter    Go Version: go1.24.7
2025-11-25T13:50:57.030Z    INFO    keda_metrics_adapter    Go OS/Arch: linux/amd64
...
I1125 13:50:57.330081       1 secure_serving.go:211] Serving securely on [::]:6443
...

Steps to Reproduce the Problem

deploy (or just render) the chart with helm values that include

logging:
  metricServer:
    zapLevel: info
    zapEncoder: json

Specifications

  • KEDA Version: 1.28.1
  • Platform & Version: irrelevant
  • Kubernetes Version: irrelevant
  • Scaler(s): irrelevant

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions