hashicorp/nomad · warning

No nomad log file defined

Error message

No nomad log file defined

What it means

Agent.MonitorExport with OnDisk=true streams the Nomad server's log file from disk. If a.srv.GetConfig().LogFile is empty — logging to disk was never configured — there is no file to read, so the endpoint emits this 400 stream error.

Source

Thrown at nomad/client_agent_endpoint.go:321

	// Try to forward request to remote region/server
	if args.ServerID != "" {
		serverToFwd, err := a.forwardFor(args.ServerID, region)
		if err != nil {
			handleStreamResultError(err, new(int64(400)), encoder)
			return
		}
		if serverToFwd != nil {
			//empty args.ServerID to prevent forwarding loop
			args.ServerID = ""
			a.forwardMonitorServer(conn, serverToFwd, args, encoder, decoder, "Agent.MonitorExport")
			return
		}
	}

	nomadLogPath := a.srv.GetConfig().LogFile
	if args.OnDisk && nomadLogPath == "" {
		handleStreamResultError(errors.New("No nomad log file defined"), new(int64(400)), encoder)
	}
	// NodeID was empty, ServerID was equal to this server,  monitor this server
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()
	opts := monitor.MonitorExportOpts{
		Logger:       a.srv.logger,
		LogsSince:    args.LogsSince,
		ServiceName:  args.ServiceName,
		NomadLogPath: nomadLogPath,
		OnDisk:       args.OnDisk,
		Follow:       args.Follow,
		Context:      ctx,
	}

	frames := make(chan *sframer.StreamFrame, 32)
	errCh := make(chan error)
	var buf bytes.Buffer
	frameSize := 1024

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Set log_file in the Nomad server configuration (e.g. log_file = "/var/log/nomad/nomad.log") and restart the server.
  2. Call MonitorExport with OnDisk=false to follow in-memory/stdout logs instead of disk files.
  3. Verify the running server actually loaded the log_file config (check the process args/config).
  4. If managed by systemd, consider StdOut/StdErr journal settings or explicitly configure file logging before using OnDisk export.

Example fix

// before: server HCL, no file logging
telemetry { ... }
// after
log_file = "/var/log/nomad/nomad.log"
log_rotate_bytes = 104857600
Defensive patterns

Strategy: fallback

Validate before calling

// check server config before requesting on-disk logs
if strings.EqualFold(serverConfig.LogFile, "") {
    // log_file not set: OnDisk export will fail
}

Try / catch

err := client.Agent().MonitorExport(ctx, opts, fn)
if err != nil && strings.Contains(err.Error(), "No nomad log file defined") {
    // fall back to streaming non-disk logs (OnDisk=false)
}

Prevention

When it happens

Trigger: Calling MonitorExport with OnDisk=true against a server whose config has no log_file set (Nomad is logging only to stdout/stderr), so GetConfig().LogFile returns "".

Common situations: Default Nomad installs that never set log_file in the server config; operators expecting logs on disk but relying on default stdout logging; running via containers/systemd capturing stdout without file logging enabled.

Related errors


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