grafana/k6 · error

couldn't parse the loki limit as a number %w

Error message

couldn't parse the loki limit as a number %w

What it means

Raised in LokiHookOptions.parseArgs when the limit value cannot be parsed by strconv.Atoi. It means the Loki log-entry limit is not an integer. The at-fault input is the non-numeric limit value; the Atoi error is wrapped with %w.

Source

Thrown at internal/log/loki.go:167

	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":
			opts.Limit, err = strconv.Atoi(value)
			if err != nil {
				return fmt.Errorf("couldn't parse the loki limit as a number %w", err)
			}
			if opts.Limit < 1 {
				return fmt.Errorf("loki limit needs to be a positive number, is %d", opts.Limit)
			}
		case "msgMaxSize":
			opts.MsgMaxSize, err = strconv.Atoi(value)
			if err != nil {
				return fmt.Errorf("couldn't parse the loki msgMaxSize as a number %w", err)
			}
			if opts.MsgMaxSize < 1 {
				return fmt.Errorf("loki msgMaxSize needs to be a positive number, is %d", opts.MsgMaxSize)
			}
		case "level":
			opts.Level = value
		case "allowedLabels":
			opts.AllowedLabels = strings.Split(value, ",")
		default:
			if after, ok := strings.CutPrefix(key, "label."); ok {

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Provide a plain integer, e.g. limit=100
  2. Remove quotes or stray characters around the number
  3. Ensure the value has no units or decimals
Defensive patterns

Strategy: validation

When it happens

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