{"record":{"id":"9ede2930998075da","repo":"crowdsecurity/crowdsec","slug":"victorialogs-is-not-ready-w","errorCode":null,"errorMessage":"VictoriaLogs is not ready: %w","messagePattern":"VictoriaLogs is not ready: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/victorialogs/run.go","lineNumber":26,"sourceCode":"\t\"gopkg.in/tomb.v2\"\n\n\t\"github.com/crowdsecurity/crowdsec/pkg/acquisition/configuration\"\n\t\"github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/victorialogs/internal/vlclient\"\n\t\"github.com/crowdsecurity/crowdsec/pkg/metrics\"\n\t\"github.com/crowdsecurity/crowdsec/pkg/pipeline\"\n)\n\n// OneShotAcquisition reads a set of file and returns when done\nfunc (s *Source) OneShotAcquisition(ctx context.Context, out chan pipeline.Event, t *tomb.Tomb) error {\n\ts.logger.Debug(\"VictoriaLogs one shot acquisition\")\n\ts.Client.SetTomb(t)\n\n\treadyCtx, cancel := context.WithTimeout(ctx, s.Config.WaitForReady)\n\tdefer cancel()\n\n\terr := s.Client.Ready(readyCtx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"VictoriaLogs is not ready: %w\", err)\n\t}\n\n\tctx, cancel = context.WithCancel(ctx)\n\tdefer cancel()\n\n\trespChan, err := s.getResponseChan(ctx, false)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error when starting acquisition: %w\", err)\n\t}\n\n\tfor {\n\t\tselect {\n\t\tcase <-t.Dying():\n\t\t\ts.logger.Debug(\"VictoriaLogs one shot acquisition stopped\")\n\t\t\treturn nil\n\t\tcase resp, ok := <-respChan:\n\t\t\tif !ok {\n\t\t\t\ts.logger.Info(\"VictoriaLogs acquisition completed\")","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/victorialogs/run.go#L8-L44","documentation":"During one-shot acquisition, the client polls VictoriaLogs' health endpoint every 500ms until the `WaitForReady` timeout elapses. If the server never answers 200/healthy in that window, `Ready` returns the timeout or last error, and CrowdSec aborts the acquisition run.","triggerScenarios":"`s.Client.Ready(readyCtx)` fails because the `WaitForReady` duration (config) expires before VictoriaLogs answers health checks with HTTP 200: server down, wrong URL, slow startup, or context canceled because the parent run is dying.","commonSituations":"Running `cscli` one-shot acquire against a VictoriaLogs instance that is still starting; wrong `url:` in acquis config; VictoriaLogs resource-starved and slow to become healthy; `wait_for_ready` left at a small default while the server takes minutes to boot on first start.","solutions":["Start/verify VictoriaLogs and confirm `curl '<url>/health'` returns 200.","Increase the `wait_for_ready` (WaitForReady) duration in the acquisition config.","Fix the `url`/`prefix` in the config if health checks go to the wrong host/port.","Check VictoriaLogs logs for slow startup (index replay, disk pressure) and free resources.","If intentionally stopping acquisition, the wrapped `context.Canceled` is benign — ignore."],"exampleFix":"# before\nsource: victorialogs\nwait_for_ready: 5s\n# after\nsource: victorialogs\nwait_for_ready: 2m  # allow slow first-start VictoriaLogs to become healthy","handlingStrategy":"validation","validationCode":"// before one-shot acquisition\nclient := http.Client{Timeout: 5 * time.Second}\nresp, err := client.Get(cfg.URL + \"/health\")\nif err != nil || resp.StatusCode != 200 {\n    return fmt.Errorf(\"VictoriaLogs not ready at %s\", cfg.URL)\n}","typeGuard":null,"tryCatchPattern":"if err := acquire(ctx); err != nil {\n    if errors.Is(err, context.DeadlineExceeded) {\n        // readiness timeout: retry later with a larger WaitForReady\n    }\n}","preventionTips":["Set wait_for_ready larger than worst-case server startup time","Check /health returns 200 before running one-shot jobs","Orchestrate startup order (healthcheck/depends_on)","Watch VictoriaLogs startup logs for slow readiness"],"tags":["timeout","health-check","victorialogs"],"backgroundTag":"request-timeout","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"}