grafana/k6 · error

error while parsing loki configuration %w

Error message

error while parsing loki configuration %w

What it means

Wraps a strvals.Parse failure in LokiHookOptions.parseArgs. It fires when the `loki=...` configuration line is not valid key=value token syntax (bad quoting/separators). The at-fault input is the malformed loki config line; the strvals error is wrapped with %w.

Source

Thrown at internal/log/loki.go:146

	if line != "loki" {
		logOutput, _, _ := strings.Cut(line, "=")
		if logOutput != "loki" {
			return nil, fmt.Errorf("loki configuration should be in the form `loki=url-to-push` but is `%s`", line)
		}

		if err := opts.parseArgs(line); err != nil {
			return nil, err
		}
	}

	return NewLokiHook(fallbackLogger, opts)
}

func (opts *LokiHookOptions) parseArgs(line string) error {
	tokens, err := strvals.Parse(line)
	if err != nil {
		return fmt.Errorf("error while parsing loki configuration %w", err)
	}

	for _, token := range tokens {
		key := token.Key
		value := token.Value

		var err error
		switch key {
		case "loki":
			opts.Addr = value
		case "pushPeriod":
			opts.PushPeriod, err = time.ParseDuration(value)
			if err != nil {
				return fmt.Errorf("couldn't parse the loki pushPeriod %w", err)
			}
		case "profile":
			opts.Profile = true
		case "limit":

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Ensure valid key=value syntax, e.g. loki=http://localhost:3100/loki/api/v1/push
  2. Correctly quote URLs or values containing special characters
  3. Inspect the wrapped strvals error for the exact syntax problem
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/log/loki.go:146 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/d938b19016ca11f9. Report an issue: GitHub.