crowdsecurity/crowdsec · error
invalid log_level in dsn: %w
Error message
invalid log_level in dsn: %w
What it means
ConfigureByDSN parses the optional `log_level` DSN parameter with log.ParseLevel (logrus). The value must be one of the accepted level names (panic, fatal, error, warn, info, debug, trace); anything else is wrapped with "invalid log_level in dsn".
Source
Thrown at pkg/acquisition/modules/victorialogs/config.go:188
s.Config.MaxFailureDuration = duration
} else {
s.Config.MaxFailureDuration = 5 * time.Second // for OneShot mode it doesn't make sense to have longer duration
}
if limit := params.Get("limit"); limit != "" {
limit, err := strconv.Atoi(limit)
if err != nil {
return fmt.Errorf("invalid limit in dsn: %w", err)
}
s.Config.Limit = limit
}
if logLevel := params.Get("log_level"); logLevel != "" {
level, err := log.ParseLevel(logLevel)
if err != nil {
return fmt.Errorf("invalid log_level in dsn: %w", err)
}
s.Config.LogLevel = level
s.logger.Logger.SetLevel(level)
}
s.Config.URL = fmt.Sprintf("%s://%s", scheme, u.Host)
if u.User != nil {
s.Config.Auth.Username = u.User.Username()
s.Config.Auth.Password, _ = u.User.Password()
}
clientConfig := vlclient.Config{
URL: s.Config.URL,
Headers: s.Config.Headers,
Limit: s.Config.Limit,
Query: s.Config.Query,
Since: s.Config.Since,View on GitHub (pinned to 909b515798)
Solutions
- Use one of: trace, debug, info, warn, error, fatal, panic (case-insensitive)
- Replace unsupported names like `notice`, `verbose`, or `warning` with the closest valid level (e.g. `warning` -> `warn`)
- Omit the parameter to keep the logger at its default level
- Check the wrapped logrus error, which lists the accepted values
Example fix
// before url: victorialogs+http://127.0.0.1:8428?log_level=warning // after url: victorialogs+http://127.0.0.1:8428?log_level=warn
Defensive patterns
Strategy: validation
Validate before calling
const VALID = ["panic","fatal","error","warn","info","debug","trace"]
const lvl = p.searchParams.get("log_level")
if (lvl && !VALID.includes(lvl.toLowerCase())) {
throw new Error(`invalid log_level: ${lvl}`)
} Prevention
- Memorize the logrus level set: panic, fatal, error, warn, info, debug, trace
- Map syslog/other-framework names to logrus equivalents (warning->warn, notice->info)
- Leave log_level unset to inherit the service's default level
When it happens
Trigger: Providing `log_level=` in the DSN with an unrecognized level name, e.g. `log_level=verbose`, `log_level=WARNING`, `log_level=notice`.
Common situations: Users familiar with syslog severities (notice, warning spelled differently) or other logging frameworks using names logrus does not accept; matching is case-insensitive but names must be exact logrus levels.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- unknown level %s: %w
- invalid log_level in dsn: %w
- cannot parse VictoriaLogs acquisition configuration: %s
- while parsing dsn '%s': %w
- invalid DSN %s for VictoriaLogs source, must start with vict
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/401916dd9d417dc1.
Report an issue: GitHub.