grafana/k6 · error

invalid trend stat '%s', unknown format

Error message

invalid trend stat '%s', unknown format

What it means

Raised by parsePercentile (used for trend column stats, e.g. summaryTrendStats) when a stat is neither a known static stat (avg, min, med, max, count) nor a percentile of the form p(N). It is a format guard for the trend-stat notation.

Source

Thrown at metrics/sample.go:176

		if staticStat, ok := staticResolvers[stat]; ok {
			result[stat] = staticStat
			continue
		}

		percentile, err := parsePercentile(stat)
		if err != nil {
			return nil, err
		}
		result[stat] = dynamicResolver(percentile)
	}

	return result, nil
}

// parsePercentile is a helper function to parse and validate percentile notations
func parsePercentile(stat string) (float64, error) {
	if !strings.HasPrefix(stat, "p(") || !strings.HasSuffix(stat, ")") {
		return 0, fmt.Errorf("invalid trend stat '%s', unknown format", stat)
	}

	percentile, err := strconv.ParseFloat(stat[2:len(stat)-1], 64)

	if err != nil || (percentile < 0) || (percentile > 100) {
		return 0, fmt.Errorf("invalid percentile trend stat value '%s', provide a number between 0 and 100", stat)
	}

	return percentile, nil
}

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Use static stats (avg, min, med, max, count) or percentile notation like p(95)
  2. Check for typos such as p95 without parentheses
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at metrics/sample.go:176 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/c54fd79434ba40dc. Report an issue: GitHub.