grafana/k6 · error

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

Error message

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

What it means

The msgMaxSize option of the Loki log output could not be converted to an integer by strconv.Atoi. parseArgs wraps the parse failure, meaning the supplied value is not a valid base-10 number string (empty, fractional, or contains non-digits).

Source

Thrown at internal/log/loki.go:175

		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 {
				opts.Labels = append(opts.Labels, [2]string{after, value})

				continue
			} else if after, ok := strings.CutPrefix(key, "header."); ok {
				opts.Headers = append(opts.Headers, [2]string{after, value})

				continue
			}

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Provide msgMaxSize as a plain integer string, e.g. --log-output=loki=...,msgMaxSize=500000
  2. Check for typos, quotes, or unit suffixes in the msgMaxSize value
Defensive patterns

Strategy: validation

When it happens

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