mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 05:04:05 -08:00
Merge pull request #788 from prometheus/fabxc/cfg-re
config: error on missing regex in relabel config.
This commit is contained in:
commit
bc09484608
|
@ -409,7 +409,13 @@ type RelabelConfig struct {
|
|||
func (c *RelabelConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
*c = DefaultRelabelConfig
|
||||
type plain RelabelConfig
|
||||
return unmarshal((*plain)(c))
|
||||
if err := unmarshal((*plain)(c)); err != nil {
|
||||
return err
|
||||
}
|
||||
if c.Regex == nil {
|
||||
return fmt.Errorf("relabel configuration requires a regular expression")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Regexp encapsulates a regexp.Regexp and makes it YAML marshallable.
|
||||
|
|
|
@ -164,6 +164,9 @@ var expectedErrors = []struct {
|
|||
}, {
|
||||
filename: "regex.bad.yml",
|
||||
errMsg: "error parsing regexp",
|
||||
}, {
|
||||
filename: "regex_missing.bad.yml",
|
||||
errMsg: "relabel configuration requires a regular expression",
|
||||
}, {
|
||||
filename: "rules.bad.yml",
|
||||
errMsg: "invalid rule file path",
|
||||
|
|
4
config/testdata/regex_missing.bad.yml
vendored
Normal file
4
config/testdata/regex_missing.bad.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
scrape_configs:
|
||||
- job_name: prometheus
|
||||
relabel_configs:
|
||||
- source_labels: ['blub']
|
Loading…
Reference in a new issue