{"record":{"id":"0dd3194767533ca6","repo":"hashicorp/nomad","slug":"telemetry-in-memory-collection-interval-must-be-gr","errorCode":null,"errorMessage":"telemetry in-memory collection interval must be greater than zero","messagePattern":"telemetry in-memory collection interval must be greater than zero","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/agent/config.go","lineNumber":1525,"sourceCode":"\t\t\tblocked = append(blocked, rule[1:])\n\t\tdefault:\n\t\t\treturn nil, nil, fmt.Errorf(\"Filter rule must begin with either '+' or '-': %q\", rule)\n\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\"`","sourceCodeStart":1507,"sourceCodeEnd":1543,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/config.go#L1507-L1543","documentation":"Telemetry in-memory metrics require a strictly positive collection interval: how often the agent samples metrics into the in-memory ring buffer. Validate() rejects values <= 0 because a non-positive interval would mean metrics are never collected (or division-by-zero style scheduling errors downstream).","triggerScenarios":"Agent telemetry config enables in-memory metrics and sets the internal inMemoryCollectionInterval (derived from e.g. `metrics_interval` or in-memory specific settings) to 0 or a negative duration, then calls the telemetry Validate().","commonSituations":"Setting interval to 0 to try to disable collection while leaving in-memory metrics enabled; automation computing the interval to zero; unit mixups producing a near-zero parsed duration.","solutions":["Set a positive collection interval (e.g. `metrics_interval = \"10s\"`) in the telemetry block.","If you want collection disabled, disable the in-memory metrics feature itself rather than setting interval 0.","Check where the interval value originates (flags/env/templates) and guard against zero there."],"exampleFix":"// before\ntelemetry {\n  in_memory_collection_interval = 0\n}\n\n// after\ntelemetry {\n  in_memory_collection_interval = \"10s\"\n}","handlingStrategy":"validation","validationCode":"if t := cfg.Telemetry; t != nil && t.InMemoryCollectionInterval <= 0 {\n    return errors.New(\"telemetry collection interval must be > 0\")\n}","typeGuard":"func positiveInterval(d time.Duration) bool { return d > 0 }","tryCatchPattern":null,"preventionTips":["Disable the in-memory sink itself rather than zeroing its interval.","Use templated defaults (e.g. 10s) instead of computed values that can hit zero.","Check env/flag overrides that could clobber the interval."],"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"}