diff --git a/cmd/wekafsplugin/main.go b/cmd/wekafsplugin/main.go index 95fecbef0..2bb334604 100644 --- a/cmd/wekafsplugin/main.go +++ b/cmd/wekafsplugin/main.go @@ -49,7 +49,6 @@ func init() { file = short return file + ":" + strconv.Itoa(line) } - log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.RFC3339}).With().Caller().Logger() } @@ -82,6 +81,7 @@ var ( tracingUrl = flag.String("tracingurl", "", "OpenTelemetry / Jaeger endpoint") allowInsecureHttps = flag.Bool("allowinsecurehttps", false, "Allow insecure HTTPS connection without cert validation") alwaysAllowSnapshotVolumes = flag.Bool("alwaysallowsnapshotvolumes", false, "Allow snapshot-based volumes even when Weka cluster doesn't support capacity enforcement") + usejsonlogging = flag.Bool("usejsonlogging", false, "Use structured JSON logging rather than human-readable console log formatting") // Set by the build process version = "" @@ -107,6 +107,9 @@ func mapVerbosity(verbosity int) zerolog.Level { func main() { flag.Parse() + if !*usejsonlogging { + log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.RFC3339}).With().Caller().Logger() + } zerolog.SetGlobalLevel(mapVerbosity(*verbosity)) csiMode = wekafs.GetCsiPluginMode(csimodetext) diff --git a/deploy/helm/csi-wekafsplugin/templates/controllerserver-statefulset.yaml b/deploy/helm/csi-wekafsplugin/templates/controllerserver-statefulset.yaml index 9f101709f..d44462644 100755 --- a/deploy/helm/csi-wekafsplugin/templates/controllerserver-statefulset.yaml +++ b/deploy/helm/csi-wekafsplugin/templates/controllerserver-statefulset.yaml @@ -121,6 +121,9 @@ spec: {{- if .Values.pluginConfig.allowInsecureHttps }} - "--allowinsecurehttps" {{- end }} + {{- if .Values.useJsonLogging }} + - "--usejsonlogging" + {{- end }} ports: - containerPort: 9898 name: healthz diff --git a/deploy/helm/csi-wekafsplugin/templates/nodeserver-daemonset-selinux.yaml b/deploy/helm/csi-wekafsplugin/templates/nodeserver-daemonset-selinux.yaml index 422bd64f7..47addfb19 100644 --- a/deploy/helm/csi-wekafsplugin/templates/nodeserver-daemonset-selinux.yaml +++ b/deploy/helm/csi-wekafsplugin/templates/nodeserver-daemonset-selinux.yaml @@ -66,6 +66,9 @@ spec: {{- if .Values.pluginConfig.allowInsecureHttps }} - "--allowinsecurehttps" {{- end }} + {{- if .Values.useJsonLogging }} + - "--usejsonlogging" + {{- end }} ports: - containerPort: 9898 name: healthz @@ -186,4 +189,4 @@ spec: secret: secretName: {{ .Values.legacyVolumeSecretName }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/deploy/helm/csi-wekafsplugin/templates/nodeserver-daemonset.yaml b/deploy/helm/csi-wekafsplugin/templates/nodeserver-daemonset.yaml index 3e8b30350..9a2c5b43a 100644 --- a/deploy/helm/csi-wekafsplugin/templates/nodeserver-daemonset.yaml +++ b/deploy/helm/csi-wekafsplugin/templates/nodeserver-daemonset.yaml @@ -64,6 +64,9 @@ spec: {{- if .Values.pluginConfig.allowInsecureHttps }} - "--allowinsecurehttps" {{- end }} + {{- if .Values.useJsonLogging }} + - "--usejsonlogging" + {{- end }} ports: - containerPort: 9898 name: healthz diff --git a/deploy/helm/csi-wekafsplugin/values.yaml b/deploy/helm/csi-wekafsplugin/values.yaml index d9b4557e0..183d47eb6 100644 --- a/deploy/helm/csi-wekafsplugin/values.yaml +++ b/deploy/helm/csi-wekafsplugin/values.yaml @@ -36,6 +36,8 @@ nodePluginTolerations: *globalPluginTolerations nodeSelector: {} # -- Log level of CSI plugin logLevel: 5 +# -- Use JSON structured logging instead of human-readable logging format (for exporting logs to structured log parser) +useJsonLogging: false # -- for migration of pre-CSI 0.7.0 volumes only, default API secret. Must reside in same namespace as the plugin legacyVolumeSecretName: "" # -- Optional CSI Plugin priorityClassName