hashicorp/nomad · error

service name must include 'nomad

Error message

service name must include 'nomad

What it means

ScanServiceName requires every validated service name to contain the substring 'nomad', ensuring exported journald units are identifiable as Nomad-managed. If strings.Contains(input, "nomad") is false, it returns this error (note the missing closing quote in the message is a literal quirk). This prevents users from monitoring arbitrary non-Nomad systemd units through this endpoint.

Source

Thrown at command/agent/monitor/export_monitor.go:132

		logCh:        make(chan []byte, bufSize),
		bufSize:      bufSize,
		ExportReader: exportReader,
	}

	return &sw, nil
}

// ScanServiceName checks that the length, prefix and suffix conform to
// systemd conventions and ensures the service name includes the word 'nomad'
func ScanServiceName(input string) error {
	prefix := ""
	// invalid if prefix and suffix together are > 255 char
	if len(input) > 255 {
		return errors.New("service name too long")
	}

	if isNomad := strings.Contains(input, "nomad"); !isNomad {
		return errors.New(`service name must include 'nomad`)
	}

	// if there is a suffix, check against list of valid suffixes
	// and set prefix to exclude suffix index, else set prefix
	splitInput := strings.Split(input, ".")
	if len(splitInput) < 2 {
		prefix = input
	} else {
		suffix := splitInput[len(splitInput)-1]
		validSuffix := []string{
			"service",
			"socket",
			"device",
			"mount",
			"automount",
			"swap",
			"target",
			"path",

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Rename or select the correct unit name so it includes 'nomad', e.g. `nomad-client.service` or `nomad-job-xyz.service`.
  2. Check the actual unit exists with `systemctl list-units 'nomad*'` and pass that exact name.
  3. If you intend to monitor non-Nomad services, use journalctl/systemd tooling instead of Nomad's export monitor.
  4. Fix typos in configured service names in the monitoring request or agent config.

Example fix

// before
ScanServiceName("client.service")
// after
ScanServiceName("nomad-client.service")
Defensive patterns

Strategy: validation

Validate before calling

if !strings.Contains(serviceName, "nomad") {
    return errors.New("service name must include 'nomad'; use e.g. nomad-client.service")
}

Try / catch

if err := monitor.ScanServiceName(name); err != nil {
    if strings.Contains(err.Error(), "must include 'nomad") {
        return fmt.Errorf("%q is not a Nomad-managed unit; check `systemctl list-units 'nomad*'`", name)
    }
    return err
}

Prevention

When it happens

Trigger: Passing a systemd service name without the word 'nomad' anywhere in it to AgentMonitorExport or the CLI reader — e.g. `"docker.service"`, `"consul.service"`, or `"myapp.service"`.

Common situations: Users trying to export logs of non-Nomad services; typos like `nomd-client.service`; custom unit naming that drops the nomad prefix; misunderstanding that the API is Nomad-log-only.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/154b9b927e1585d2. Report an issue: GitHub.