mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 06:04:05 -08:00
test label name validation
This commit is contained in:
parent
8f77d271b1
commit
23be3dab53
|
@ -312,7 +312,7 @@ func TestRelabel(t *testing.T) {
|
||||||
"a": "some-name-value",
|
"a": "some-name-value",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ // invalid target_label ""
|
{ // invalid target_labels
|
||||||
input: model.LabelSet{
|
input: model.LabelSet{
|
||||||
"a": "some-name-value",
|
"a": "some-name-value",
|
||||||
},
|
},
|
||||||
|
@ -324,6 +324,20 @@ func TestRelabel(t *testing.T) {
|
||||||
Replacement: "${1}",
|
Replacement: "${1}",
|
||||||
TargetLabel: model.LabelName("${3}"),
|
TargetLabel: model.LabelName("${3}"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
SourceLabels: model.LabelNames{"a"},
|
||||||
|
Regex: config.MustNewRegexp("some-([^-]+)-([^,]+)"),
|
||||||
|
Action: config.RelabelReplace,
|
||||||
|
Replacement: "${1}",
|
||||||
|
TargetLabel: model.LabelName("0${3}"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
SourceLabels: model.LabelNames{"a"},
|
||||||
|
Regex: config.MustNewRegexp("some-([^-]+)-([^,]+)"),
|
||||||
|
Action: config.RelabelReplace,
|
||||||
|
Replacement: "${1}",
|
||||||
|
TargetLabel: model.LabelName("-${3}"),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
output: model.LabelSet{
|
output: model.LabelSet{
|
||||||
"a": "some-name-value",
|
"a": "some-name-value",
|
||||||
|
@ -353,20 +367,14 @@ func TestRelabel(t *testing.T) {
|
||||||
Regex: config.MustNewRegexp(".*?(?:,|^)label:([^=]+)=([^,]+).*"),
|
Regex: config.MustNewRegexp(".*?(?:,|^)label:([^=]+)=([^,]+).*"),
|
||||||
Action: config.RelabelReplace,
|
Action: config.RelabelReplace,
|
||||||
Replacement: "${2}",
|
Replacement: "${2}",
|
||||||
TargetLabel: model.LabelName("__meta_sd_add_label_${1}"),
|
TargetLabel: model.LabelName("${1}"),
|
||||||
},
|
|
||||||
{
|
|
||||||
Regex: config.MustNewRegexp("__meta_sd_add_label_(.*)"),
|
|
||||||
Replacement: "${1}",
|
|
||||||
Action: config.RelabelLabelMap,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
output: model.LabelSet{
|
output: model.LabelSet{
|
||||||
"__meta_sd_tags": "path:/secret,job:some-job,label:foo=bar",
|
"__meta_sd_tags": "path:/secret,job:some-job,label:foo=bar",
|
||||||
"__metrics_path__": "/secret",
|
"__metrics_path__": "/secret",
|
||||||
"job": "some-job",
|
"job": "some-job",
|
||||||
"__meta_sd_add_label_foo": "bar",
|
"foo": "bar",
|
||||||
"foo": "bar",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue