Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/4017.added.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
feat: Allow journald directory to be overriden
1 change: 1 addition & 0 deletions deploy/helm/sumologic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/"` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 "/" "" }}
Copy link
Contributor

@chan-tim-sumo chan-tim-sumo Oct 27, 2025

Choose a reason for hiding this comment

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

just thinking here, what if the user sets something ambiguous or an invalid name?
(as in, would journal work if the mount path isn't /var/log/journal?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's likely that journal messages would not be ingested if this is neither /var/log/journal nor /run/log/journal . Perhaps this should be a toggle to use either of the two, or maybe a setting equivalent to Storage=?

https://www.freedesktop.org/software/systemd/man/latest/journald.conf.html#Storage=

readOnly: true
{{- if $daemonset.extraVolumeMounts }}
{{ toYaml $daemonset.extraVolumeMounts | indent 8 }}
Expand Down Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,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 }}
Expand Down Expand Up @@ -191,9 +191,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 }}
Expand Down
3 changes: 3 additions & 0 deletions deploy/helm/sumologic/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
Expand Down
79 changes: 79 additions & 0 deletions tests/helm/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)
}