grafana/k6 · error

loki msgMaxSize needs to be a positive number, is %d

Error message

loki msgMaxSize needs to be a positive number, is %d

What it means

The msgMaxSize option of the Loki log output parsed successfully as an integer but is below 1. msgMaxSize caps the size of individual messages pushed to Loki, so zero or negative values are meaningless and are rejected by parseArgs.

Source

Thrown at internal/log/loki.go:178

				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
			}

			return fmt.Errorf("unknown loki config key %s", key)
		}

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Set msgMaxSize to a positive integer, e.g. --log-output=loki=...,msgMaxSize=1000
  2. Omit msgMaxSize to use the default maximum message size
Defensive patterns

Strategy: validation

When it happens

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