crowdsecurity/crowdsec · error

cannot parse loki acquisition configuration: %s

Error message

cannot parse loki acquisition configuration: %s

What it means

UnmarshalConfig for the loki source unmarshals the acquisition YAML into the Configuration struct; malformed YAML or invalid values make the loki acquisition configuration unparseable, so the source is rejected at load time.

Source

Thrown at pkg/acquisition/modules/loki/config.go:45

type Configuration struct {
	URL                               string            `yaml:"url"`    // Loki url
	Prefix                            string            `yaml:"prefix"` // Loki prefix
	Query                             string            `yaml:"query"`  // LogQL query
	Limit                             int               `yaml:"limit"`  // Limit of logs to read
	DelayFor                          time.Duration     `yaml:"delay_for"`
	Since                             time.Duration     `yaml:"since"`
	Headers                           map[string]string `yaml:"headers"`        // HTTP headers for talking to Loki
	WaitForReady                      time.Duration     `yaml:"wait_for_ready"` // Retry interval, default is 10 seconds
	Auth                              AuthConfiguration `yaml:"auth"`
	MaxFailureDuration                time.Duration     `yaml:"max_failure_duration"` // Max duration of failure before stopping the source
	NoReadyCheck                      bool              `yaml:"no_ready_check"`       // Bypass /ready check before starting
	configuration.DataSourceCommonCfg                   `yaml:",inline"`
}

func (l *Source) UnmarshalConfig(yamlConfig []byte) error {
	err := yaml.UnmarshalWithOptions(yamlConfig, &l.Config, yaml.Strict())
	if err != nil {
		return fmt.Errorf("cannot parse loki acquisition configuration: %s", yaml.FormatError(err, false, false))
	}

	if l.Config.Query == "" {
		return errors.New("loki query is mandatory")
	}

	if l.Config.WaitForReady == 0 {
		l.Config.WaitForReady = 10 * time.Second
	}

	if l.Config.DelayFor < 0*time.Second || l.Config.DelayFor > 5*time.Second {
		return errors.New("delay_for should be a value between 1s and 5s")
	}

	if l.Config.Mode == "" {
		l.Config.Mode = configuration.TAIL_MODE
	}

View on GitHub (pinned to 909b515798)

Solutions

  1. Fix YAML syntax or field type errors reported in the message
  2. Check url, query, limit etc. have the documented types
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/acquisition/modules/loki/config.go:45 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06). Data as JSON: /api/errors/bbfe2ec0d26159c8. Report an issue: GitHub.