grafana/k6 · error

couldn't parse the loki pushPeriod %w

Error message

couldn't parse the loki pushPeriod %w

What it means

Raised in LokiHookOptions.parseArgs when the pushPeriod value cannot be parsed by time.ParseDuration. It means the Loki push interval is not a valid Go duration string. The at-fault input is the invalid pushPeriod value; the ParseDuration error is wrapped with %w.

Source

Thrown at internal/log/loki.go:160

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
		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)

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Use a valid duration like pushPeriod=1s, 500ms, or 1m
  2. Include a time unit — bare numbers (e.g. pushPeriod=10) are invalid
  3. See Go's time.ParseDuration format for accepted units
Defensive patterns

Strategy: validation

When it happens

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