From 427b76d723a019316eecf65871cbe9452ebdef70 Mon Sep 17 00:00:00 2001 From: Jesse Davis Date: Wed, 15 Oct 2025 09:57:53 -0400 Subject: [PATCH 1/6] feat: allow change of hardcoded journald location --- .../sumologic/conf/logs/collector/otelcol/config.yaml | 2 +- .../templates/logs/collector/otelcol/daemonset.yaml | 8 ++++---- .../logs/collector/otellogswindows/daemonset.yaml | 8 ++++---- deploy/helm/sumologic/values.yaml | 3 +++ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/deploy/helm/sumologic/conf/logs/collector/otelcol/config.yaml b/deploy/helm/sumologic/conf/logs/collector/otelcol/config.yaml index 36b51b5da4..1ae660a981 100644 --- a/deploy/helm/sumologic/conf/logs/collector/otelcol/config.yaml +++ b/deploy/helm/sumologic/conf/logs/collector/otelcol/config.yaml @@ -61,7 +61,7 @@ receivers: {{- if .Values.sumologic.logs.systemd.enabled }} journald: - directory: /var/log/journal + directory: {{ .Values.sumologic.logs.systemd.journaldDirectory }} ## This is not a full equivalent of fluent-bit filtering as fluent-bit filters by `_SYSTEMD_UNIT` ## Here is filtering by `UNIT` units: diff --git a/deploy/helm/sumologic/templates/logs/collector/otelcol/daemonset.yaml b/deploy/helm/sumologic/templates/logs/collector/otelcol/daemonset.yaml index e2aa47d7a9..a72feab83b 100644 --- a/deploy/helm/sumologic/templates/logs/collector/otelcol/daemonset.yaml +++ b/deploy/helm/sumologic/templates/logs/collector/otelcol/daemonset.yaml @@ -111,8 +111,8 @@ spec: readOnly: true - mountPath: /var/lib/storage/otc name: file-storage - - mountPath: /var/log/journal - name: varlogjournal + - mountPath: {{ $.Values.sumologic.logs.systemd.journaldDirectory }} + name: {{ $.Values.sumologic.logs.systemd.journaldDirectory | replace "/" "" }} readOnly: true {{- if $daemonset.extraVolumeMounts }} {{ toYaml $daemonset.extraVolumeMounts | indent 8 }} @@ -178,9 +178,9 @@ spec: type: DirectoryOrCreate name: file-storage - hostPath: - path: /var/log/journal/ + path: {{ $.Values.sumologic.logs.systemd.journaldDirectory }} type: "" - name: varlogjournal + name: {{ $.Values.sumologic.logs.systemd.journaldDirectory | replace "/" "" }} {{- if $daemonset.extraVolumes }} {{ toYaml $daemonset.extraVolumes | indent 6 }} {{- end }} diff --git a/deploy/helm/sumologic/templates/logs/collector/otellogswindows/daemonset.yaml b/deploy/helm/sumologic/templates/logs/collector/otellogswindows/daemonset.yaml index 0325f3315f..297697b56b 100644 --- a/deploy/helm/sumologic/templates/logs/collector/otellogswindows/daemonset.yaml +++ b/deploy/helm/sumologic/templates/logs/collector/otellogswindows/daemonset.yaml @@ -116,8 +116,8 @@ spec: readOnly: true - mountPath: /var/lib/storage/otc name: file-storage - - mountPath: /var/log/journal - name: varlogjournal + - mountPath: {{ include "sumologic.logs.systemd.journaldDirectory" $ctx }} + name: {{ include "sumologic.logs.systemd.journaldDirectory" $ctx | replace "/" "" }} readOnly: true {{- if $daemonset.extraVolumeMounts }} {{ toYaml $daemonset.extraVolumeMounts | indent 8 }} @@ -191,9 +191,9 @@ spec: type: DirectoryOrCreate name: file-storage - hostPath: - path: /var/log/journal/ + path: {{ include "sumologic.logs.systemd.journaldDirectory" $ctx }} type: "" - name: varlogjournal + name: {{ include "sumologic.logs.systemd.journaldDirectory" $ctx | replace "/" "" }} {{- if $daemonset.extraVolumes }} {{ toYaml $daemonset.extraVolumes | indent 6 }} {{- end }} diff --git a/deploy/helm/sumologic/values.yaml b/deploy/helm/sumologic/values.yaml index c5cad9d1dc..912d89a712 100644 --- a/deploy/helm/sumologic/values.yaml +++ b/deploy/helm/sumologic/values.yaml @@ -398,6 +398,9 @@ sumologic: # units: # - docker.service + ## Behavior specified by journald.conf + journaldDirectory: /var/log/journal + otelcol: ## Extra processors for systemd logs. See https://help.sumologic.com/docs/send-data/kubernetes/collecting-logs/ for details. extraProcessors: [] From 84ba7d4ca52045bccdbf898047bdbbadd0e3ce7c Mon Sep 17 00:00:00 2001 From: Jesse Davis Date: Wed, 15 Oct 2025 11:02:29 -0400 Subject: [PATCH 2/6] also update windows daemonset, properly set / on end of hostPath --- .../sumologic/templates/logs/collector/otelcol/daemonset.yaml | 2 +- .../templates/logs/collector/otellogswindows/daemonset.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deploy/helm/sumologic/templates/logs/collector/otelcol/daemonset.yaml b/deploy/helm/sumologic/templates/logs/collector/otelcol/daemonset.yaml index a72feab83b..deda5ec2a7 100644 --- a/deploy/helm/sumologic/templates/logs/collector/otelcol/daemonset.yaml +++ b/deploy/helm/sumologic/templates/logs/collector/otelcol/daemonset.yaml @@ -178,7 +178,7 @@ spec: type: DirectoryOrCreate name: file-storage - hostPath: - path: {{ $.Values.sumologic.logs.systemd.journaldDirectory }} + path: {{ $.Values.sumologic.logs.systemd.journaldDirectory }}/ type: "" name: {{ $.Values.sumologic.logs.systemd.journaldDirectory | replace "/" "" }} {{- if $daemonset.extraVolumes }} diff --git a/deploy/helm/sumologic/templates/logs/collector/otellogswindows/daemonset.yaml b/deploy/helm/sumologic/templates/logs/collector/otellogswindows/daemonset.yaml index 297697b56b..18a26e49bc 100644 --- a/deploy/helm/sumologic/templates/logs/collector/otellogswindows/daemonset.yaml +++ b/deploy/helm/sumologic/templates/logs/collector/otellogswindows/daemonset.yaml @@ -191,9 +191,9 @@ spec: type: DirectoryOrCreate name: file-storage - hostPath: - path: {{ include "sumologic.logs.systemd.journaldDirectory" $ctx }} + path: {{ $.Values.sumologic.logs.systemd.journaldDirectory }}/ type: "" - name: {{ include "sumologic.logs.systemd.journaldDirectory" $ctx | replace "/" "" }} + name: {{ $.Values.sumologic.logs.systemd.journaldDirectory | replace "/" "" }} {{- if $daemonset.extraVolumes }} {{ toYaml $daemonset.extraVolumes | indent 6 }} {{- end }} From 2b0cfc5167a5b963fb9baf7e182785060f795213 Mon Sep 17 00:00:00 2001 From: Jesse Davis Date: Wed, 15 Oct 2025 11:12:02 -0400 Subject: [PATCH 3/6] also update windows daemonset, remove incorrect include --- .../templates/logs/collector/otellogswindows/daemonset.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy/helm/sumologic/templates/logs/collector/otellogswindows/daemonset.yaml b/deploy/helm/sumologic/templates/logs/collector/otellogswindows/daemonset.yaml index 18a26e49bc..8e710752e4 100644 --- a/deploy/helm/sumologic/templates/logs/collector/otellogswindows/daemonset.yaml +++ b/deploy/helm/sumologic/templates/logs/collector/otellogswindows/daemonset.yaml @@ -116,8 +116,8 @@ spec: readOnly: true - mountPath: /var/lib/storage/otc name: file-storage - - mountPath: {{ include "sumologic.logs.systemd.journaldDirectory" $ctx }} - name: {{ include "sumologic.logs.systemd.journaldDirectory" $ctx | replace "/" "" }} + - mountPath: {{ $.Values.sumologic.logs.systemd.journaldDirectory }} + name: {{ $.Values.sumologic.logs.systemd.journaldDirectory | replace "/" "" }} readOnly: true {{- if $daemonset.extraVolumeMounts }} {{ toYaml $daemonset.extraVolumeMounts | indent 8 }} From 1176f6cb6a4b8aaa5f2761d8279bac1a7f210f4c Mon Sep 17 00:00:00 2001 From: Jesse Davis Date: Thu, 16 Oct 2025 14:30:07 -0400 Subject: [PATCH 4/6] tests for journald directory --- tests/helm/logs_test.go | 79 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/tests/helm/logs_test.go b/tests/helm/logs_test.go index 4fb3401728..ed07838d09 100644 --- a/tests/helm/logs_test.go +++ b/tests/helm/logs_test.go @@ -558,6 +558,30 @@ sumologic: require.Equal(t, "sumologic|my_logs_namespace", otelConfig.Processors.SourceContainers.Exclude.Namespace) } +func TestCollectorConfigmapChangeJournaldDirectory(t *testing.T) { + t.Parallel() + templatePath := "templates/logs/collector/otelcol/configmap.yaml" + valuesYaml := ` +sumologic: + logs: + systemd: + journaldDirectory: /run/log/journal +` + otelConfigYaml := GetOtelConfigYaml(t, valuesYaml, templatePath) + + var otelConfig struct { + Receivers struct { + Journald struct { + Directory string `yaml:"directory"` + } `yaml:"journald"` + } `yaml:"receivers"` + } + err := yaml.Unmarshal([]byte(otelConfigYaml), &otelConfig) + require.NoError(t, err) + + require.Equal(t, "/run/log/journal", otelConfig.Receivers.Journald.Directory) +} + func TestCollectorDaemonsetUpdateStrategy(t *testing.T) { t.Parallel() @@ -587,3 +611,58 @@ otellogs: require.Equal(t, "50%", logsCollectorDaemonset.Spec.UpdateStrategy.RollingUpdate.MaxUnavailable) } + +func TestJournaldDirectoryDaemonsetMounts(t *testing.T) { + t.Parallel() + + valuesYaml := ` +sumologic: + logs: + systemd: + journaldDirectory: /run/log/journal +` + templatePath := "templates/logs/collector/otelcol/daemonset.yaml" + + renderedTemplate, err := RenderTemplateFromValuesStringE(t, valuesYaml, templatePath) + require.NoError(t, err) + + var logsCollectorDaemonset struct { + Spec struct { + Template struct { + Spec struct { + Containers []struct { + VolumeMounts []struct { + MountPath string `yaml:"mountPath"` + Name string `yaml:"name"` + } `yaml:"volumeMounts"` + } `yaml:"containers"` + Volumes []struct { + HostPath struct { + Path string `yaml:"path"` + } `yaml:"hostPath"` + Name string `yaml:"name"` + } `yaml:"volumes"` + } `yaml:"spec"` + } `yaml:"template"` + } `yaml:"spec"` + } + err = yaml.Unmarshal([]byte(renderedTemplate), &logsCollectorDaemonset) + require.NoError(t, err) + + volumeChangeFound := false + volumeMountChangeFound := false + for _, container := range logsCollectorDaemonset.Spec.Template.Spec.Containers { + for _, volumemount := range container.VolumeMounts { + if volumemount.Name == "runlogjournal" && volumemount.MountPath == "/run/log/journal" { + volumeMountChangeFound = true + } + } + } + for _, volume := range logsCollectorDaemonset.Spec.Template.Spec.Volumes { + if volume.Name == "runlogjournal" && volume.HostPath.Path == "/run/log/journal/" { + volumeChangeFound = true + } + } + + require.True(t, volumeChangeFound && volumeMountChangeFound) +} From 58cc09019658a5c6850818cb3a42f28962884ca3 Mon Sep 17 00:00:00 2001 From: Jesse Davis Date: Thu, 16 Oct 2025 14:53:37 -0400 Subject: [PATCH 5/6] add README line --- deploy/helm/sumologic/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/deploy/helm/sumologic/README.md b/deploy/helm/sumologic/README.md index 60a136401a..79f8218e3d 100644 --- a/deploy/helm/sumologic/README.md +++ b/deploy/helm/sumologic/README.md @@ -74,6 +74,7 @@ The following table lists the configurable parameters of the Sumo Logic chart an | `sumologic.logs.otelcol.useDefaultExporters` | Set to `false` to use only `sumologic.logs.otelcol.extraExporters`. See [Sumo Logic documentation](https://help.sumologic.com/docs/send-data/kubernetes/collecting-logs/) for details. | `true` | | `sumologic.logs.container.perContainerAnnotationsEnabled` | Enable container-level pod annotations. | `false` | | `sumologic.logs.container.perContainerAnnotationPrefixes` | Defines the list of prefixes of container-level pod annotations. | `[]` | +| `sumologic.logs.systemd.journaldDirectory` | Set the directory read by the journald receiver. | `/var/log/journal` | | `sumologic.logs.systemd.sourceName` | Set the \_sourceName metadata field in Sumo Logic. | `"%{_sourceName}"` | | `sumologic.logs.systemd.sourceCategory` | Set the \_sourceCategory metadata field in Sumo Logic. | `"system"` | | `sumologic.logs.systemd.sourceCategoryPrefix` | Set the prefix, for \_sourceCategory metadata. | `"kubernetes/"` | From 805d8bae8c36648be8f44b89ae8fafd5d5130817 Mon Sep 17 00:00:00 2001 From: Jesse Davis Date: Fri, 17 Oct 2025 11:44:55 -0400 Subject: [PATCH 6/6] add changelog --- .changelog/4017.added.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 .changelog/4017.added.txt diff --git a/.changelog/4017.added.txt b/.changelog/4017.added.txt new file mode 100644 index 0000000000..f755bb5bca --- /dev/null +++ b/.changelog/4017.added.txt @@ -0,0 +1 @@ +feat: Allow journald directory to be overriden