{"record":{"id":"cf853a8b7c636d18","repo":"hashicorp/nomad","slug":"journald-log-monitoring-only-available-on-linux","errorCode":null,"errorMessage":"journald log monitoring only available on linux","messagePattern":"journald log monitoring only available on linux","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/agent/monitor/export_monitor.go","lineNumber":86,"sourceCode":"\ntype ExportReader struct {\n\tio.Reader\n\tCmd    *exec.Cmd\n\tUseCli bool\n\tFollow bool\n}\n\n// NewExportMonitor validates and prepares the appropriate reader before\n// returning a new ExportMonitor or the appropriate error\nfunc NewExportMonitor(opts MonitorExportOpts) (*ExportMonitor, error) {\n\tvar (\n\t\texportReader *ExportReader\n\t\tbufSize      int\n\t)\n\n\tif runtime.GOOS != \"linux\" &&\n\t\topts.ServiceName != \"\" {\n\t\treturn nil, errors.New(\"journald log monitoring only available on linux\")\n\t}\n\n\tif opts.BufSize == 0 {\n\t\tbufSize = defaultBufSize\n\t} else {\n\t\tbufSize = opts.BufSize\n\t}\n\n\tif opts.OnDisk && opts.ServiceName == \"\" {\n\t\te, prepErr := fileReader(opts)\n\t\tif prepErr != nil {\n\t\t\treturn nil, prepErr\n\t\t}\n\t\texportReader = e\n\t}\n\n\tif opts.ServiceName != \"\" && !opts.OnDisk {\n\t\te, prepErr := cliReader(opts)","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/monitor/export_monitor.go#L68-L104","documentation":"NewExportMonitor in command/agent/monitor/export_monitor.go only supports journald-based log monitoring on Linux. If opts.ServiceName is non-empty (requesting journald log export) while runtime.GOOS is not linux, construction fails with this error. journald is a systemd/Linux facility so there is no implementation on other OSes.","triggerScenarios":"Requesting an export monitor with a ServiceName set (journald monitoring) on a Nomad agent/CLI running on darwin (macOS) or windows — e.g. running `nomad monitor`-style export with a systemd service name from a Mac.","commonSituations":"Developers running Nomad on macOS/Windows workstations issuing commands configured for a Linux server; copy-pasted config referencing journald service names on non-systemd hosts; CI runners on non-Linux OS.","solutions":["Run the command on a Linux host with systemd/journald where the service actually exists.","Remove the ServiceName option (or clear it) when monitoring is not needed on non-Linux platforms so journald monitoring is not requested.","Set the journald service name only via config applied to Linux clients, e.g. gate the config block by platform.","If on Linux this still fires, verify the build/runtime — it means runtime.GOOS reports non-linux, which should not occur on a standard Linux build."],"exampleFix":"// before (on macOS)\nNewExportMonitor(ExportMonitorOptions{ServiceName: \"nomad-client.service\", ...})\n// after\nif runtime.GOOS != \"linux\" {\n    // drop journald option\n    NewExportMonitor(ExportMonitorOptions{BufSize: 4096})\n}","handlingStrategy":"validation","validationCode":"if runtime.GOOS != \"linux\" && serviceName != \"\" {\n    // skip or error before calling NewExportMonitor\n    return errors.New(\"journald export requires linux; drop ServiceName or run on linux\")\n}","typeGuard":null,"tryCatchPattern":"m, err := monitor.NewExportMonitor(opts)\nif err != nil {\n    if strings.Contains(err.Error(), \"only available on linux\") {\n        log.Warn(\"journald monitoring unavailable on this OS; continuing without it\")\n        return nil\n    }\n    return err\n}","preventionTips":["Only set ServiceName in configs deployed to Linux/systemd hosts.","Gate journald monitoring config by OS in provisioning tooling.","Run remote-monitoring commands on the Linux server, not a macOS workstation."],"tags":["journald","platform","linux","log-monitoring"],"backgroundTag":"unsupported-platform","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}