grafana/k6 · error
unable to validate threshold %q on metric %s; reason: parsin
Error message
unable to validate threshold %q on metric %s; reason: parsing threshold failed %w
What it means
Inside Thresholds.Validate, parsing the threshold expression (threshold.parsed via thresholdExpression) failed for the quoted threshold applied to the named metric. The expression string does not conform to the threshold grammar (bad aggregation method, missing/unknown operator, or malformed right-hand-side value).
Source
Thrown at metrics/thresholds.go:266
return errext.WithExitCodeIfNone(parseErr, exitcodes.InvalidConfig)
}
// Obtain the metric the thresholds apply to from the registry.
// if the metric doesn't exist, then we return an error indicating
// the InvalidConfig exitcode should be used.
metric := r.Get(parsedMetricName)
if metric == nil {
err := fmt.Errorf("%w defined on %s; reason: no metric name %q found", ErrInvalidThreshold, metricName, metricName)
return errext.WithExitCodeIfNone(err, exitcodes.InvalidConfig)
}
for _, threshold := range ts.Thresholds {
// Return a digestable error if we attempt to validate a threshold
// that hasn't been parsed yet.
if threshold.parsed == nil {
thresholdExpression, err := parseThresholdExpression(threshold.Source)
if err != nil {
return fmt.Errorf("unable to validate threshold %q on metric %s; reason: "+
"parsing threshold failed %w", threshold.Source, metricName, err)
}
threshold.parsed = thresholdExpression
}
// If the threshold's expression aggregation method is not
// supported for the metric we validate against, then we return
// an error indicating the InvalidConfig exitcode should be used.
if !metric.Type.supportsAggregationMethod(threshold.parsed.AggregationMethod) {
err := fmt.Errorf(
"%w %q applied on metric %s; reason: "+
"unsupported aggregation method %s on metric of type %s. "+
"supported aggregation methods for this metric are: %s",
ErrInvalidThreshold, threshold.Source, metricName,
threshold.parsed.AggregationMethod, metric.Type,
strings.Join(metric.Type.supportedAggregationMethods(), ", "),
)View on GitHub (pinned to 01ffac6f24)
Solutions
- Fix the quoted threshold string, e.g. use 'avg<300', 'p(99)<1000', 'count>0', 'rate<0.1'
- Ensure the operator is one of > >= <= < == === != and the right side is a plain number
- Ensure the aggregation method is valid for the metric type (e.g. no 'avg' on a counter)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at metrics/thresholds.go:266 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/bf2edbb3f315cc08.
Report an issue: GitHub.