hashicorp/nomad · error
No nomad log file defined
Error message
No nomad log file defined
What it means
The agent 'monitor' endpoint with on_disk=true tails the Nomad agent's own log file. The file path comes from the agent configuration (log_file). If on_disk is requested but no log file is configured on the agent, there is nothing to tail, so the endpoint returns this 400 error instead of streaming.
Solutions
- Set log_file in the agent's config (e.g. log_file = "/var/log/nomad/") and restart the agent before using on_disk=true
- Use on_disk=false to stream in-memory logs instead of the file
- Make the client check/fall back when on-disk logging is unavailable
- Standardize log_file across all agent configs
Example fix
// before (agent config) # no log_file set // after log_file = "/var/log/nomad/"
Defensive patterns
Strategy: validation
Validate before calling
if req.OnDisk {
// confirm the agent has log_file configured (e.g. via agent self)
self, err := client.Agent().Self()
if err != nil { return err }
cfg := self.Config["Client"]
if lf, ok := cfg["LogFile"].(string); !ok || lf == "" {
return errors.New("on_disk requested but agent has no log_file configured")
}
} Try / catch
resp, err := client.Agent().Monitor(ctx, ch, &api.MonitorQuery{OnDisk: true})
if err != nil {
if strings.Contains(err.Error(), "No nomad log file defined") {
// fall back to in-memory log streaming
return client.Agent().Monitor(ctx, ch, &api.MonitorQuery{OnDisk: false})
}
return err
} Prevention
- Always set log_file in agent config when using on_disk log streaming
- Probe agent self/config before enabling on_disk
- Prefer in-memory streaming unless file persistence is required
When it happens
Trigger: Calling the Agent Monitor API with on_disk=true against an agent whose config does not set log_file (the default config may leave it empty or only set log_json/log_level).
Common situations: Agents running with default configuration that never set log_file; clients assuming on-disk logging is always enabled; mixed fleets where some agents configure log_file and others do not; upgrades where log_file was removed from config.
Understand the failure class
Background: "missing required config value" errors: why libraries refuse to start when a configuration key is empty, unset, or blank — this error's family across 48 libraries.
Related errors
- failed to create stderr logfile for
- failed to create stdout logfile for
- nil logger passed
- No nomad log file defined
- Unknown log level
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/a378da6f2c4db867.
Report an issue: GitHub.
Appendix: source
Thrown at client/agent_endpoint.go:220
encoder := codec.NewEncoder(conn, structs.MsgpackHandle)
if err := decoder.Decode(&args); err != nil {
handleStreamResultError(err, new(int64(500)), encoder)
return
}
// Check acl
if aclObj, err := a.c.ResolveToken(args.AuthToken); err != nil {
handleStreamResultError(err, new(int64(403)), encoder)
return
} else if !aclObj.AllowAgentRead() {
handleStreamResultError(structs.ErrPermissionDenied, new(int64(403)), encoder)
return
}
nomadLogPath := a.c.GetConfig().LogFile
if args.OnDisk && nomadLogPath == "" {
handleStreamResultError(errors.New("No nomad log file defined"), new(int64(400)), encoder)
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
opts := monitor.MonitorExportOpts{
Logger: a.c.logger,
LogsSince: args.LogsSince,
ServiceName: args.ServiceName,
NomadLogPath: nomadLogPath,
OnDisk: args.OnDisk,
Follow: args.Follow,
Context: ctx,
}
frames := make(chan *sframer.StreamFrame, streamFramesBuffer)
errCh := make(chan error)
var buf bytes.Buffer
frameSize := 1024View on GitHub (pinned to 482b49bf1a)