grafana/k6 · error
metric '%s' does not exist in the script
Error message
metric '%s' does not exist in the script
What it means
A threshold (or submetric) was defined in the test options for a metric name that is not present in the metric registry. getThresholdMetricOrSubmetric splits the name at '{' and looks up the base metric name; the lookup returned nil, meaning no metric with that name was ever emitted or registered.
Source
Thrown at internal/metrics/engine/engine.go:69
return me, nil
}
// CreateIngester returns a pseudo-Output that uses the given metric samples to
// update the engine's inner state.
func (me *MetricsEngine) CreateIngester() *OutputIngester {
return &OutputIngester{
logger: me.logger.WithField("component", "metrics-engine-ingester"),
metricsEngine: me,
cardinality: newCardinalityControl(),
}
}
func (me *MetricsEngine) getThresholdMetricOrSubmetric(name string) (*metrics.Metric, error) {
metricDefinition, submetricDefinition, _ := strings.Cut(name, "{")
metric := me.registry.Get(metricDefinition)
if metric == nil {
return nil, fmt.Errorf("metric '%s' does not exist in the script", metricDefinition)
}
if len(submetricDefinition) == 0 { // no sub-metric
return metric, nil
}
if submetricDefinition[len(submetricDefinition)-1] != '}' {
return nil, fmt.Errorf("missing ending bracket, sub-metric format needs to be 'metric{key:value}'")
}
sm, err := metric.AddSubmetric(submetricDefinition[:len(submetricDefinition)-1])
if err != nil {
return nil, err
}
if sm.Metric.Observed {
// Do not repeat warnings for the same sub-metrics
return sm.Metric, nil
}View on GitHub (pinned to 01ffac6f24)
Solutions
- Fix the metric name spelling in options.thresholds
- Register/emit the metric (e.g. via a custom Trend/Counter/Rate/Gauge or by enabling the relevant built-in metric)
- Remove the threshold for the nonexistent metric
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/metrics/engine/engine.go:69 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/5256ee6e6b34d5fa.
Report an issue: GitHub.