crowdsecurity/crowdsec · error
empty %s DSN
Error message
empty %s DSN
What it means
The docker DSN must name a container: its host part is taken as container name/ID. If parsedURL.Host is empty (e.g. just `docker://`), configuration fails with this error because there is no container to attach logs from.
Source
Thrown at pkg/acquisition/modules/docker/config.go:235
d.runningServiceState = tracker.NewTracker[*ContainerConfig]()
d.Config.Mode = configuration.CAT_MODE
d.logger = logger
d.Config.Labels = labels
opts := []client.Opt{
client.FromEnv,
}
d.containerLogsOptions = &client.ContainerLogsOptions{
ShowStdout: d.Config.FollowStdout,
ShowStderr: d.Config.FollowStdErr,
Follow: false,
}
containerNameOrID := parsedURL.Host
if containerNameOrID == "" {
return fmt.Errorf("empty %s DSN", d.GetName()+"://")
}
d.Config.ContainerName = append(d.Config.ContainerName, containerNameOrID)
// we add it as an ID also so user can provide docker name or docker ID
d.Config.ContainerID = append(d.Config.ContainerID, containerNameOrID)
parameters := parsedURL.Query()
for k, v := range parameters {
switch k {
case "log_level":
if len(v) != 1 {
return errors.New("only one 'log_level' parameters is required, not many")
}
lvl, err := log.ParseLevel(v[0])
if err != nil {
return fmt.Errorf("unknown level %s: %w", v[0], err)
}View on GitHub (pinned to 909b515798)
Solutions
- Add the container name or ID after the scheme: docker://mycontainer.
- If the name comes from a variable, verify it is set/non-empty at config render time.
- Alternatively configure via YAML with container_name/container_id lists instead of a DSN.
Example fix
// before log_path: 'docker://' // after log_path: 'docker://nginx-proxy'
Defensive patterns
Strategy: validation
Validate before calling
u, _ := url.Parse(dsn)
if u != nil && u.Host == "" {
return errors.New("docker DSN requires a container name or ID: docker://<name>")
} Prevention
- Never leave the host part empty in a docker:// DSN.
- When templating, assert the container variable is non-empty.
- Prefer YAML container_name lists for config generated from variables.
When it happens
Trigger: ConfigureByDSN called with a DSN like `docker://` or `docker://?follow_stdout=true` where the host (container name or ID) is missing.
Common situations: acquis.yaml entry `log_path: docker://` with container name forgotten; templated config where the variable expanded to empty; reading container name from an unset env var.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- empty journalctl:// DSN
- empty loki host
- while parsing DockerAcquisition configuration: %s
- unsupported mode %s for docker datasource
- container_name_regexp: %w
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/70ee2c733cac0e8a.
Report an issue: GitHub.