grafana/k6 · error

missing ending bracket, sub-metric format needs to be 'metri

Error message

missing ending bracket, sub-metric format needs to be 'metric{key:value}'

What it means

A threshold was declared on a submetric (name contains '{'), but the part after '{' does not end with '}'. The required submetric selector syntax is metric{key:value}; the closing bracket is missing from the threshold key.

Source

Thrown at internal/metrics/engine/engine.go:77

		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
	}

	if _, ok := sm.Tags.Get("vu"); ok {
		me.logger.Warnf(
			"The high-cardinality 'vu' metric tag was made non-indexable in k6 v0.41.0, so thresholds"+
				" like '%s' that are based on it won't work correctly.",
			name,
		)
	}

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Add the closing brace, e.g. http_req_duration{status:200} instead of http_req_duration{status:200
  2. Verify the selector contains a tag key:value pair inside the braces
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/metrics/engine/engine.go:77 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/c9e2fdcfc5076060. Report an issue: GitHub.