grafana/k6 · error

loki configuration should be in the form `loki=url-to-push`

Error message

loki configuration should be in the form `loki=url-to-push` but is `%s`

What it means

A validation guard in LokiFromConfigLine. The --log-output value for Loki must be either bare `loki` or start with `loki=`; it fires when the prefix before '=' is not 'loki'. The at-fault input is the malformed log-output configuration line.

Source

Thrown at internal/log/loki.go:132

		h.droppedLabels[params[0]] = params[1]
	}

	h.droppedMsg = h.filterLabels(h.droppedLabels, h.droppedMsg)
	h.client = &http.Client{Timeout: h.pushPeriod}

	return h, nil
}

// LokiFromConfigLine returns a new logrus.Hook
// that pushes logrus.Entrys to loki and is configured
// through the provided line.
func LokiFromConfigLine(fallbackLogger logrus.FieldLogger, line string) (AsyncHook, error) {
	var opts LokiHookOptions

	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

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Use --log-output=loki or --log-output=loki=url-to-push
  2. Use the correct output type keyword for other outputs (stdout, file=...)
  3. Check for typos or extra whitespace before '='
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/log/loki.go:132 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/e72b56390812f2a6. Report an issue: GitHub.