grafana/k6 · error
InvalidConfig
InvalidConfig
Error message
unable to validate threshold expressions; reason: %w
What it means
Wraps an error raised while Thresholds.Validate checks each threshold expression against a metric from the registry. It is a generic wrapper: the real cause (carried by %w) is typically a parse failure of a threshold expression during validation, meaning the expression string does not match the 'aggregation method operator value' grammar.
Source
Thrown at metrics/thresholds.go:247
t.parsed = parsed
}
return nil
}
// ErrInvalidThreshold indicates a threshold is not valid
var ErrInvalidThreshold = errors.New("invalid threshold")
// Validate ensures a threshold definition is consistent with the metric it applies to.
// Given a metric registry and a metric name to apply the expressions too, Validate will
// assert that each threshold expression uses an aggregation method that's supported by the
// provided metric. It returns an error otherwise.
// Note that this function expects the passed in thresholds to have been parsed already, and
// have their Parsed (ThresholdExpression) field already filled.
func (ts *Thresholds) Validate(metricName string, r *Registry) error {
parsedMetricName, _, err := ParseMetricName(metricName)
if err != nil {
parseErr := fmt.Errorf("unable to validate threshold expressions; reason: %w", err)
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 {View on GitHub (pinned to 01ffac6f24)
Solutions
- Inspect the wrapped error to see which threshold expression failed to parse
- Rewrite threshold expressions in the form 'method<op>value', e.g. 'p(95)<500' or 'rate<0.01'
- Use only supported aggregation methods (avg, min, max, med, p(N), count, rate, value)
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at metrics/thresholds.go:247 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/c6d19769ba651798.
Report an issue: GitHub.