{"record":{"id":"c77765ccd6d4ae51","repo":"hashicorp/nomad","slug":"telemetry-in-memory-retention-period-must-be-great","errorCode":null,"errorMessage":"telemetry in-memory retention period must be greater than zero","messagePattern":"telemetry in-memory retention period must be greater than zero","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/agent/config.go","lineNumber":1528,"sourceCode":"\t\t}\n\t}\n\treturn allowed, blocked, nil\n}\n\n// Validate the telemetry configuration options. These are used by the agent,\n// regardless of mode, so can live here rather than a structs package. It is\n// safe to call, without checking whether the config object is nil first.\nfunc (t *Telemetry) Validate() error {\n\tif t == nil {\n\t\treturn nil\n\t}\n\n\t// Ensure we have durations that are greater than zero.\n\tif t.inMemoryCollectionInterval <= 0 {\n\t\treturn errors.New(\"telemetry in-memory collection interval must be greater than zero\")\n\t}\n\tif t.inMemoryRetentionPeriod <= 0 {\n\t\treturn errors.New(\"telemetry in-memory retention period must be greater than zero\")\n\t}\n\n\t// Ensure the in-memory durations do not conflict.\n\tif t.inMemoryCollectionInterval > t.inMemoryRetentionPeriod {\n\t\treturn errors.New(\"telemetry in-memory collection interval cannot be greater than retention period\")\n\t}\n\n\treturn nil\n}\n\n// Eventlog is the configuration for the Windows Eventlog\ntype Eventlog struct {\n\t// Enabled controls if Nomad agent logs are sent to the\n\t// Windows eventlog.\n\tEnabled bool `hcl:\"enabled\"`\n\t// Level of logs to send to eventlog. May be set to higher\n\t// severity than LogLevel but lower level will be ignored.\n\tLevel string `hcl:\"level\"`","sourceCodeStart":1510,"sourceCodeEnd":1546,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/config.go#L1510-L1546","documentation":"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.","triggerScenarios":"Telemetry config's inMemoryRetentionPeriod parses to 0 or a negative duration (collection interval check already passed) when the telemetry Validate() runs.","commonSituations":"Setting retention to 0 intending 'keep forever' or 'disable'; copy/paste config errors; unit confusion yielding a near-zero duration.","solutions":["Set a positive retention period (e.g. in_memory_retention_period / equivalent to \"1h\").","Ensure retention period >= collection interval so the next consistency check passes.","If retention is unwanted, disable in-memory metrics instead of zeroing the duration."],"exampleFix":"// before\ntelemetry {\n  in_memory_retention_period = 0\n}\n\n// after\ntelemetry {\n  in_memory_retention_period = \"1h\"\n}","handlingStrategy":"validation","validationCode":"if t := cfg.Telemetry; t != nil && t.InMemoryRetentionPeriod <= 0 {\n    return errors.New(\"telemetry retention period must be > 0\")\n}","typeGuard":"func positiveRetention(d time.Duration) bool { return d > 0 }","tryCatchPattern":null,"preventionTips":["Keep retention >= collection interval.","Include explicit duration units to avoid near-zero parses.","Review telemetry block after any config generation change."],"tags":["config-validation","telemetry","metrics","duration"],"backgroundTag":"invalid-config-value","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}