grafana/k6 · error

submetric criteria for metric '%s' cannot be empty

Error message

submetric criteria for metric '%s' cannot be empty

What it means

Raised by Metric.AddSubmetric when the tag-filter portion of a threshold submetric name (the part inside {..} after the parent metric) is empty or whitespace-only, e.g. a threshold declared on 'my_metric{}'.

Source

Thrown at metrics/metric.go:43

	Observed   bool         `json:"-"`
}

// A Submetric represents a filtered dataset based on a parent metric.
type Submetric struct {
	Name   string  `json:"name"`
	Suffix string  `json:"suffix"` // TODO: rename?
	Tags   *TagSet `json:"tags"`

	Metric *Metric `json:"-"`
	Parent *Metric `json:"-"`
}

// AddSubmetric creates a new submetric from the key:value threshold definition
// and adds it to the metric's submetrics list.
func (m *Metric) AddSubmetric(keyValues string) (*Submetric, error) {
	keyValues = strings.TrimSpace(keyValues)
	if len(keyValues) == 0 {
		return nil, fmt.Errorf("submetric criteria for metric '%s' cannot be empty", m.Name)
	}
	kvs := strings.Split(keyValues, ",")
	tags := m.registry.RootTagSet()
	for _, kv := range kvs {
		if kv == "" {
			continue
		}
		k, v, _ := strings.Cut(kv, ":")

		key := strings.Trim(strings.TrimSpace(k), `"'`)
		if v == "" {
			tags = tags.With(key, "")
			continue
		}

		value := strings.Trim(strings.TrimSpace(v), `"'`)
		tags = tags.With(key, value)
	}

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Provide at least one tag filter, e.g. my_metric{status:200}
  2. Remove the empty curly braces if no filtering is intended
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at metrics/metric.go:43 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/10c9d34bb8526357. Report an issue: GitHub.