mirror of
https://github.com/prometheus/prometheus
synced 2024-12-26 08:33:06 +00:00
Handle null Regex in the config as the empty regex. (#2150)
This commit is contained in:
parent
fc4d9c13e8
commit
d1ece12c70
@ -1017,6 +1017,9 @@ func (c *RelabelConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
if err := checkOverflow(c.XXX, "relabel_config"); err != nil {
|
||||
return err
|
||||
}
|
||||
if c.Regex.Regexp == nil {
|
||||
c.Regex = MustNewRegexp("")
|
||||
}
|
||||
if c.Modulus == 0 && c.Action == RelabelHashMod {
|
||||
return fmt.Errorf("relabel configuration for hashmod requires non-zero modulus")
|
||||
}
|
||||
|
@ -115,6 +115,12 @@ var expectedConf = &Config{
|
||||
Regex: DefaultRelabelConfig.Regex,
|
||||
Replacement: "static",
|
||||
Action: RelabelReplace,
|
||||
}, {
|
||||
TargetLabel: "abc",
|
||||
Separator: ";",
|
||||
Regex: MustNewRegexp(""),
|
||||
Replacement: "static",
|
||||
Action: RelabelReplace,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
3
config/testdata/conf.good.yml
vendored
3
config/testdata/conf.good.yml
vendored
@ -54,6 +54,9 @@ scrape_configs:
|
||||
target_label: cde
|
||||
- replacement: static
|
||||
target_label: abc
|
||||
- regex:
|
||||
replacement: static
|
||||
target_label: abc
|
||||
|
||||
bearer_token_file: valid_token_file
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user