1
0
mirror of https://github.com/prometheus/prometheus.git synced 2025-02-06 16:14:36 +00:00

Merge pull request #15974 from jhesketh/jhesketh/utf-label-replace

Allow UTF-8 labels in label_replace
This commit is contained in:
Björn Rabenstein 2025-02-05 20:49:36 +01:00 committed by GitHub
commit fa1bd02c99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -1612,7 +1612,7 @@ func (ev *evaluator) evalLabelReplace(ctx context.Context, args parser.Expressio
if err != nil { if err != nil {
panic(fmt.Errorf("invalid regular expression in label_replace(): %s", regexStr)) panic(fmt.Errorf("invalid regular expression in label_replace(): %s", regexStr))
} }
if !model.LabelNameRE.MatchString(dst) { if !model.LabelName(dst).IsValid() {
panic(fmt.Errorf("invalid destination label name in label_replace(): %s", dst)) panic(fmt.Errorf("invalid destination label name in label_replace(): %s", dst))
} }

View File

@ -466,7 +466,7 @@ eval instant at 0m label_replace(testmetric, "dst", "", "dst", ".*")
eval_fail instant at 0m label_replace(testmetric, "dst", "value-$1", "src", "(.*") eval_fail instant at 0m label_replace(testmetric, "dst", "value-$1", "src", "(.*")
# label_replace fails when the destination label name is not a valid Prometheus label name. # label_replace fails when the destination label name is not a valid Prometheus label name.
eval_fail instant at 0m label_replace(testmetric, "invalid-label-name", "", "src", "(.*)") eval_fail instant at 0m label_replace(testmetric, "\xff", "", "src", "(.*)")
# label_replace fails when there would be duplicated identical output label sets. # label_replace fails when there would be duplicated identical output label sets.
eval_fail instant at 0m label_replace(testmetric, "src", "", "", "") eval_fail instant at 0m label_replace(testmetric, "src", "", "", "")