{"record":{"id":"69e52ed3dd3de279","repo":"grafana/k6","slug":"unable-to-run-thresholds-reason-unknown-sink-typ","errorCode":null,"errorMessage":"unable to run Thresholds; reason: unknown sink type","messagePattern":"unable to run Thresholds; reason: unknown sink type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"metrics/thresholds.go","lineNumber":214,"sourceCode":"\n\t\t// Parse the percentile thresholds and insert them in\n\t\t// the sinks mapping.\n\t\tfor _, threshold := range ts.Thresholds {\n\t\t\tif threshold.parsed.AggregationMethod != tokenPercentile {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tkey := fmt.Sprintf(\"p(%g)\", threshold.parsed.AggregationValue.Float64)\n\t\t\tts.sinked[key] = sinkImpl.P(threshold.parsed.AggregationValue.Float64 / 100)\n\t\t}\n\tcase *RateSink:\n\t\t// We want to avoid division by zero, which\n\t\t// would lead to [#2520](https://github.com/grafana/k6/issues/2520)\n\t\tif sinkImpl.Total > 0 {\n\t\t\tts.sinked[\"rate\"] = float64(sinkImpl.Trues) / float64(sinkImpl.Total)\n\t\t}\n\tdefault:\n\t\treturn false, fmt.Errorf(\"unable to run Thresholds; reason: unknown sink type\")\n\t}\n\n\treturn ts.runAll(duration)\n}\n\n// Parse parses the Thresholds and fills each Threshold.parsed field with the result.\n// It effectively asserts they are syntaxically correct.\nfunc (ts *Thresholds) Parse() error {\n\tfor _, t := range ts.Thresholds {\n\t\tparsed, err := parseThresholdExpression(t.Source)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tt.parsed = parsed\n\t}\n\n\treturn nil","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/metrics/thresholds.go#L196-L232","documentation":"Thresholds.Run switches on the concrete sink type of the metric the thresholds apply to; the default branch fires when the metric's Sink is not one of the supported types (Counter, Gauge, Trend, Rate). This means thresholds were configured on a metric whose sink implementation the threshold engine cannot read — an internal/registration inconsistency rather than a user expression problem.","triggerScenarios":"Thrown at metrics/thresholds.go:214 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check which metric the thresholds are defined on and verify it was registered with a standard type (counter, gauge, trend, rate)","If using a custom metric/extension, ensure its sink implements one of the known sink types","Report as a k6 bug if the metric is a built-in type"],"exampleFix":null,"handlingStrategy":"type-guard","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-14T00:17:10.932Z"}