{"record":{"id":"61cfa2c12c7c623c","repo":"argoproj/argo-workflows","slug":"resourcesduration-metrics-cannot-be-used-in-re","errorCode":null,"errorMessage":"'resourcesDuration.*' metrics cannot be used in real-time","messagePattern":"'resourcesDuration\\.\\*' metrics cannot be used in real-time","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/metrics/util.go","lineNumber":30,"sourceCode":"\nvar (\n\tinvalidMetricNameError  = \"metric name is invalid: names may only contain alphanumeric characters or '_'\"\n\tinvalidMetricLabelError = \"metric label '%s' is invalid: keys may only contain alphanumeric characters or '_'\"\n)\n\nfunc IsValidMetricName(name string) bool {\n\t// Use promtheus's metric name checker, despite perhaps not using prometheus\n\treturn model.LegacyValidation.IsValidMetricName(string(model.LabelValue(name))) && !strings.Contains(name, `:`)\n}\n\nfunc ValidateMetricValues(metric *wfv1.Prometheus) error {\n\tif metric.Gauge != nil {\n\t\tif metric.Gauge.Value == \"\" {\n\t\t\treturn errors.New(\"missing gauge.value\")\n\t\t}\n\t\tif metric.Gauge.Realtime != nil && *metric.Gauge.Realtime {\n\t\t\tif strings.Contains(metric.Gauge.Value, \"resourcesDuration.\") {\n\t\t\t\treturn errors.New(\"'resourcesDuration.*' metrics cannot be used in real-time\")\n\t\t\t}\n\t\t}\n\t}\n\tif metric.Counter != nil && metric.Counter.Value == \"\" {\n\t\treturn errors.New(\"missing counter.value\")\n\t}\n\tif metric.Histogram != nil && metric.Histogram.Value == \"\" {\n\t\treturn errors.New(\"missing histogram.value\")\n\t}\n\treturn nil\n}\n\nfunc ValidateMetricLabels(metrics map[string]string) error {\n\tfor name := range metrics {\n\t\tif !IsValidMetricName(name) {\n\t\t\treturn fmt.Errorf(invalidMetricLabelError, name)\n\t\t}\n\t}","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/metrics/util.go#L12-L48","documentation":"Template validation guard: a realtime gauge (gauge.realtime: true) references a resourcesDuration.* variable. Realtime gauges are evaluated continuously and cannot consume the final resource-duration metrics, which only exist after node completion.","triggerScenarios":"Thrown at workflow/metrics/util.go:30 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove realtime: true from the gauge, or","Use a different metric value that is available during execution"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}