{"record":{"id":"f5acd0f11fe130af","repo":"crowdsecurity/crowdsec","slug":"delay-for-should-be-a-value-between-1s-and-5s","errorCode":null,"errorMessage":"delay_for should be a value between 1s and 5s","messagePattern":"delay_for should be a value between 1s and 5s","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/loki/config.go","lineNumber":57,"sourceCode":"\tconfiguration.DataSourceCommonCfg                   `yaml:\",inline\"`\n}\n\nfunc (l *Source) UnmarshalConfig(yamlConfig []byte) error {\n\terr := yaml.UnmarshalWithOptions(yamlConfig, &l.Config, yaml.Strict())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot parse loki acquisition configuration: %s\", yaml.FormatError(err, false, false))\n\t}\n\n\tif l.Config.Query == \"\" {\n\t\treturn errors.New(\"loki query is mandatory\")\n\t}\n\n\tif l.Config.WaitForReady == 0 {\n\t\tl.Config.WaitForReady = 10 * time.Second\n\t}\n\n\tif l.Config.DelayFor < 0*time.Second || l.Config.DelayFor > 5*time.Second {\n\t\treturn errors.New(\"delay_for should be a value between 1s and 5s\")\n\t}\n\n\tif l.Config.Mode == \"\" {\n\t\tl.Config.Mode = configuration.TAIL_MODE\n\t}\n\n\tif l.Config.Prefix == \"\" {\n\t\tl.Config.Prefix = \"/\"\n\t}\n\n\tif !strings.HasSuffix(l.Config.Prefix, \"/\") {\n\t\tl.Config.Prefix += \"/\"\n\t}\n\n\tif l.Config.Limit == 0 {\n\t\tl.Config.Limit = lokiLimit\n\t}\n","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/loki/config.go#L39-L75","documentation":"The loki source's delay_for parameter controls how long to wait before re-querying to tolerate out-of-order entries. UnmarshalConfig rejects values below 0s (the message says between 1s and 5s but the check enforces 0s..5s) or above 5s, because Loki tailing expects this bounded retry delay.","triggerScenarios":"A loki acquisition config or loki:// DSN with `delay_for` set to a duration > 5s or < 0 (e.g. delay_for: 30s or -1s), evaluated in UnmarshalConfig or in ConfigureByDSN's delay_for parameter.","commonSituations":"Users copy the promtail delay_for semantics (unbounded) or set it large thinking it's a general poll interval.","solutions":["Set delay_for to a duration between 0s and 5s, e.g. delay_for: 1s","Remove delay_for to use the zero default","Check for unit typos (delay_for: 5m parses as 5 minutes and exceeds the limit)"],"exampleFix":"// before\ndelay_for: 30s\n// after\ndelay_for: 3s","handlingStrategy":"validation","validationCode":"d, err := time.ParseDuration(cfg.DelayFor)\nif err != nil || d < 0 || d > 5*time.Second {\n    return fmt.Errorf(\"delay_for must be between 0s and 5s\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep delay_for within 0-5s","Watch duration units (m vs s) in YAML","Prefer omitting the field to use defaults"],"tags":["config","loki","validation","duration"],"backgroundTag":"value-out-of-range","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}