hashicorp/nomad · error

telemetry in-memory retention period must be greater than ze

Error message

telemetry in-memory retention period must be greater than zero

What it means

The in-memory telemetry retention period defines how long collected metrics are kept in the agent's memory buffer, and must be strictly positive. Validate() rejects <= 0 because zero retention would discard metrics immediately, making the in-memory sink useless.

Source

Thrown at command/agent/config.go:1528

		}
	}
	return allowed, blocked, nil
}

// Validate the telemetry configuration options. These are used by the agent,
// regardless of mode, so can live here rather than a structs package. It is
// safe to call, without checking whether the config object is nil first.
func (t *Telemetry) Validate() error {
	if t == nil {
		return nil
	}

	// Ensure we have durations that are greater than zero.
	if t.inMemoryCollectionInterval <= 0 {
		return errors.New("telemetry in-memory collection interval must be greater than zero")
	}
	if t.inMemoryRetentionPeriod <= 0 {
		return errors.New("telemetry in-memory retention period must be greater than zero")
	}

	// Ensure the in-memory durations do not conflict.
	if t.inMemoryCollectionInterval > t.inMemoryRetentionPeriod {
		return errors.New("telemetry in-memory collection interval cannot be greater than retention period")
	}

	return nil
}

// Eventlog is the configuration for the Windows Eventlog
type Eventlog struct {
	// Enabled controls if Nomad agent logs are sent to the
	// Windows eventlog.
	Enabled bool `hcl:"enabled"`
	// Level of logs to send to eventlog. May be set to higher
	// severity than LogLevel but lower level will be ignored.
	Level string `hcl:"level"`

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Set a positive retention period (e.g. in_memory_retention_period / equivalent to "1h").
  2. Ensure retention period >= collection interval so the next consistency check passes.
  3. If retention is unwanted, disable in-memory metrics instead of zeroing the duration.

Example fix

// before
telemetry {
  in_memory_retention_period = 0
}

// after
telemetry {
  in_memory_retention_period = "1h"
}
Defensive patterns

Strategy: validation

Validate before calling

if t := cfg.Telemetry; t != nil && t.InMemoryRetentionPeriod <= 0 {
    return errors.New("telemetry retention period must be > 0")
}

Type guard

func positiveRetention(d time.Duration) bool { return d > 0 }

Prevention

When it happens

Trigger: Telemetry config's inMemoryRetentionPeriod parses to 0 or a negative duration (collection interval check already passed) when the telemetry Validate() runs.

Common situations: Setting retention to 0 intending 'keep forever' or 'disable'; copy/paste config errors; unit confusion yielding a near-zero duration.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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