hashicorp/nomad · warning

Unknown log level

Error message

Unknown log level

What it means

The Agent.Monitor endpoint parses args.LogLevel with go-hclog's LevelFromString; an unparsable level yields log.NoLevel, and the monitor rejects the request with this 400 stream error before forwarding to the node.

Source

Thrown at nomad/client_agent_endpoint.go:164

		return
	}

	// Check agent read permissions
	if aclObj, err := a.srv.ResolveACL(&args); err != nil {
		handleStreamResultError(err, nil, encoder)
		return
	} else if !aclObj.AllowAgentRead() {
		handleStreamResultError(structs.ErrPermissionDenied, new(int64(403)), encoder)
		return
	}

	logLevel := log.LevelFromString(args.LogLevel)
	if args.LogLevel == "" {
		logLevel = log.LevelFromString("INFO")
	}

	if logLevel == log.NoLevel {
		handleStreamResultError(errors.New("Unknown log level"), new(int64(400)), encoder)
		return
	}

	// Targeting a node, forward request to node
	if args.NodeID != "" {
		a.forwardMonitorClient(conn, args, encoder, decoder, args.NodeID, "Agent.Monitor")
		// forwarded request has ended, return
		return
	}

	region := args.RequestRegion()
	if region == "" {
		handleStreamResultError(fmt.Errorf("missing target region"), new(int64(400)), encoder)
		return
	}
	if region != a.srv.Region() {
		// Mark that we are forwarding
		args.SetForwarded()

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Set LogLevel to one of the exact go-hclog levels: TRACE, DEBUG, INFO, WARN, or ERROR.
  2. Replace "warning" with "WARN" and "err"/"fatal" with "ERROR" in scripts or CLI flags.
  3. Validate/sanitize the log level in wrapper tooling before invoking Agent.Monitor.
  4. If the level is unknown, omit it entirely — an empty LogLevel defaults to INFO.

Example fix

// before
args := &api.MonitorOpts{LogLevel: "warning"}
// after
args := &api.MonitorOpts{LogLevel: "WARN"}
Defensive patterns

Strategy: validation

Validate before calling

var validLevels = map[string]bool{"TRACE": true, "DEBUG": true, "INFO": true, "WARN": true, "ERROR": true}
if opts.LogLevel != "" && !validLevels[strings.ToUpper(opts.LogLevel)] {
    return fmt.Errorf("invalid log level %q; use TRACE|DEBUG|INFO|WARN|ERROR", opts.LogLevel)
}

Try / catch

err := client.Agent().Monitor(ctx, opts, fn)
if err != nil && strings.Contains(err.Error(), "Unknown log level") {
    opts.LogLevel = "INFO" // fall back to default and retry
}

Prevention

When it happens

Trigger: Calling Agent.Monitor (server or `nomad monitor`) with LogLevel set to a string that is not one of TRACE, DEBUG, INFO, WARN, ERROR (case-insensitive) — e.g. "verbose", "warning", "err", or a typo.

Common situations: Scripts passing arbitrary log-level flags from user input; using "warning" instead of "warn"; using "fatal" which go-hclog does not map here; empty handling only covers "", any other bad string fails.

Related errors


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