mirror of
https://github.com/prometheus/prometheus.git
synced 2025-12-01 23:51:01 +01:00
Fixes #17370 In Prometheus v3.7.0, using labelmap actions with replacement patterns containing regex variables (e.g., `$1`, `${1}`) would fail validation when `metric_name_validation_scheme` was set to `legacy`, causing Prometheus to fail at startup with: "$1" is invalid 'replacement' for labelmap action This was a regression as the same configuration worked in v3.6.0. The issue was in the validation logic: while UTF-8 validation correctly allowed `$` characters, legacy validation incorrectly used `IsValidLabelName` which rejects `$` characters. The fix ensures legacy validation uses `relabelTargetLegacy` regex which explicitly supports regex template variables. Added test cases to verify labelmap validation works with both `$1` and `${1}` replacement patterns under legacy validation scheme. Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>