grafana/k6 · error
failed parsing method from expression
Error message
failed parsing method from expression
What it means
parseThresholdAggregationMethod could not recognize the left-hand side: the input is neither one of the aggregation method keywords nor a percentile expression of the form p(number). Generic guard for any unrecognized aggregation method token in the threshold expression.
Source
Thrown at metrics/thresholds_parser.go:213
if m == input {
return m, null.Float{}, nil
}
}
// Otherwise, attempt to parse a percentile expression
if strings.HasPrefix(input, tokenPercentile+"(") && strings.HasSuffix(input, ")") {
aggregationValue, err := strconv.ParseFloat(trimDelimited("p(", input, ")"), 64)
if err != nil {
return "", null.Float{}, fmt.Errorf("malformed percentile value; reason: %w", err)
}
if math.IsNaN(aggregationValue) || aggregationValue < 0 || aggregationValue > 100 {
return "", null.Float{}, fmt.Errorf("malformed percentile value, provide a number between 0 and 100")
}
return tokenPercentile, null.FloatFrom(aggregationValue), nil
}
return "", null.Float{}, fmt.Errorf("failed parsing method from expression")
}
func trimDelimited(prefix, input, suffix string) string {
return strings.TrimSuffix(strings.TrimPrefix(input, prefix), suffix)
}
View on GitHub (pinned to 01ffac6f24)
Solutions
- Use one of the supported methods: avg, min, max, med, count, rate, value, or p(N)
- Check spelling and casing of the method name
- Confirm the method applies to the metric type the threshold is set on
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at metrics/thresholds_parser.go:213 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/03033626175081de.
Report an issue: GitHub.