{"record":{"id":"c9e2fdcfc5076060","repo":"grafana/k6","slug":"missing-ending-bracket-sub-metric-format-needs-to","errorCode":null,"errorMessage":"missing ending bracket, sub-metric format needs to be 'metric{key:value}'","messagePattern":"missing ending bracket, sub-metric format needs to be 'metric(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/metrics/engine/engine.go","lineNumber":77,"sourceCode":"\t\tmetricsEngine: me,\n\t\tcardinality:   newCardinalityControl(),\n\t}\n}\n\nfunc (me *MetricsEngine) getThresholdMetricOrSubmetric(name string) (*metrics.Metric, error) {\n\tmetricDefinition, submetricDefinition, _ := strings.Cut(name, \"{\")\n\n\tmetric := me.registry.Get(metricDefinition)\n\tif metric == nil {\n\t\treturn nil, fmt.Errorf(\"metric '%s' does not exist in the script\", metricDefinition)\n\t}\n\n\tif len(submetricDefinition) == 0 { // no sub-metric\n\t\treturn metric, nil\n\t}\n\n\tif submetricDefinition[len(submetricDefinition)-1] != '}' {\n\t\treturn nil, fmt.Errorf(\"missing ending bracket, sub-metric format needs to be 'metric{key:value}'\")\n\t}\n\tsm, err := metric.AddSubmetric(submetricDefinition[:len(submetricDefinition)-1])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif sm.Metric.Observed {\n\t\t// Do not repeat warnings for the same sub-metrics\n\t\treturn sm.Metric, nil\n\t}\n\n\tif _, ok := sm.Tags.Get(\"vu\"); ok {\n\t\tme.logger.Warnf(\n\t\t\t\"The high-cardinality 'vu' metric tag was made non-indexable in k6 v0.41.0, so thresholds\"+\n\t\t\t\t\" like '%s' that are based on it won't work correctly.\",\n\t\t\tname,\n\t\t)\n\t}","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/metrics/engine/engine.go#L59-L95","documentation":"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.","triggerScenarios":"Thrown at internal/metrics/engine/engine.go:77 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add the closing brace, e.g. http_req_duration{status:200} instead of http_req_duration{status:200","Verify the selector contains a tag key:value pair inside the braces"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}