{"record":{"id":"5ff75382e110adb4","repo":"grafana/k6","slug":"unknown-metric-s","errorCode":null,"errorMessage":"unknown metric: %s","messagePattern":"unknown metric: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/dashboard/aggregate.go","lineNumber":246,"sourceCode":"\n\tthresholds := make([]string, 0, len(tres))\n\n\tfor _, res := range tres {\n\t\tthresholds = append(thresholds, res.String())\n\t}\n\n\t_, err = agg.registry.getOrNew(name, metricType, valueType, thresholds)\n\n\treturn err\n}\n\nfunc (agg *aggregator) processPoint(data []byte) error {\n\ttimestamp := gjson.GetBytes(data, \"data.time\").Time()\n\tname := gjson.GetBytes(data, \"metric\").String()\n\n\tmetric := agg.registry.Get(name)\n\tif metric == nil {\n\t\treturn fmt.Errorf(\"%w: %s\", errUnknownMetric, name)\n\t}\n\n\ttags := agg.tagSetFrom(gjson.GetBytes(data, \"data.tags\"))\n\n\tsample := metrics.Sample{ //nolint:exhaustruct\n\t\tTime:  timestamp,\n\t\tValue: gjson.GetBytes(data, \"data.value\").Float(),\n\t\tTimeSeries: metrics.TimeSeries{ //nolint:exhaustruct\n\t\t\tMetric: metric,\n\t\t\tTags:   tags,\n\t\t},\n\t}\n\n\tcontainer := metrics.ConnectedSamples{ //nolint:exhaustruct\n\t\tSamples: []metrics.Sample{sample},\n\t\tTime:    sample.Time,\n\t\tTags:    tags,\n\t}","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/dashboard/aggregate.go#L228-L264","documentation":"The web dashboard aggregator (internal/dashboard/aggregate.go:246) processes a stream of JSON events: 'metric' events define metrics in a registry, 'point' events carry samples. processPoint looks the name up in the registry and returns errUnknownMetric (wrapped as 'unknown metric: <name>') when a sample arrives for a metric that was never defined.","triggerScenarios":"Feeding the dashboard (websocket input or replay of a recorded stream via --web-dashboard-record/export artifacts) a point event whose 'metric' name has no preceding metric-definition event; name mismatches such as sending 'http_req_duration ' vs 'http_req_duration' or sub-metric names before their parent is registered.","commonSituations":"Custom tooling that replays k6 metric JSON into the dashboard and drops definition events; scripts where metric names are constructed dynamically and injected externally; in rare cases a genuine k6 ordering bug worth reporting.","solutions":["Ensure metric definition events precede their sample points in whatever stream the dashboard consumes.","Verify metric names match exactly (no extra whitespace/case differences) between definitions and points.","If this reproduces with a plain `k6 run --web-dashboard script.js`, report it with the script to github.com/grafana/k6/issues."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// when feeding a recorded stream to the dashboard, drop points for undefined metrics\nconst defined = new Set(events.filter(e => e.type === 'metric').map(e => e.data.name));\nconst safe = events.filter(e => e.type !== 'point' || defined.has(e.metric));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never trim metric-definition events when editing recorded dashboard streams.","If it reproduces with an unmodified script, capture the k6 version and report — it indicates an ordering bug."],"tags":["dashboard","metrics","streaming","web-dashboard"],"backgroundTag":"unknown-metric-reference","analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}