grafana/k6 · error
loki limit needs to be a positive number, is %d
Error message
loki limit needs to be a positive number, is %d
What it means
The Loki log output was configured with a limit option whose parsed integer value is less than 1. The limit controls how many log lines the internal buffer holds before dropping entries, so zero or negative values are rejected by parseArgs when building Loki options from a config line.
Source
Thrown at internal/log/loki.go:170
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 {
opts.Labels = append(opts.Labels, [2]string{after, value})
continueView on GitHub (pinned to 01ffac6f24)
Solutions
- Set the limit option in the Loki config line to a positive integer, e.g. --log-output=loki=...,limit=1000
- Remove the limit key to fall back to the default limit
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/log/loki.go:170 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/e88c014967e31ec9.
Report an issue: GitHub.