mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-13 17:14:05 -08:00
parent
db4df06414
commit
458550560c
|
@ -409,7 +409,13 @@ type RelabelConfig struct {
|
||||||
func (c *RelabelConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
func (c *RelabelConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
*c = DefaultRelabelConfig
|
*c = DefaultRelabelConfig
|
||||||
type plain RelabelConfig
|
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.
|
// Regexp encapsulates a regexp.Regexp and makes it YAML marshallable.
|
||||||
|
|
|
@ -164,6 +164,9 @@ var expectedErrors = []struct {
|
||||||
}, {
|
}, {
|
||||||
filename: "regex.bad.yml",
|
filename: "regex.bad.yml",
|
||||||
errMsg: "error parsing regexp",
|
errMsg: "error parsing regexp",
|
||||||
|
}, {
|
||||||
|
filename: "regex_missing.bad.yml",
|
||||||
|
errMsg: "relabel configuration requires a regular expression",
|
||||||
}, {
|
}, {
|
||||||
filename: "rules.bad.yml",
|
filename: "rules.bad.yml",
|
||||||
errMsg: "invalid rule file path",
|
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