mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
Make sure that url for remote_read/write is not nil (#3024)
This commit is contained in:
parent
62047e5c97
commit
1bf3b91ae0
|
@ -1404,7 +1404,7 @@ func (re Regexp) MarshalYAML() (interface{}, error) {
|
|||
|
||||
// RemoteWriteConfig is the configuration for writing to remote storage.
|
||||
type RemoteWriteConfig struct {
|
||||
URL *URL `yaml:"url,omitempty"`
|
||||
URL *URL `yaml:"url"`
|
||||
RemoteTimeout model.Duration `yaml:"remote_timeout,omitempty"`
|
||||
WriteRelabelConfigs []*RelabelConfig `yaml:"write_relabel_configs,omitempty"`
|
||||
|
||||
|
@ -1424,6 +1424,9 @@ func (c *RemoteWriteConfig) UnmarshalYAML(unmarshal func(interface{}) error) err
|
|||
if err := unmarshal((*plain)(c)); err != nil {
|
||||
return err
|
||||
}
|
||||
if c.URL == nil {
|
||||
return fmt.Errorf("url for remote_write is empty")
|
||||
}
|
||||
|
||||
// The UnmarshalYAML method of HTTPClientConfig is not being called because it's not a pointer.
|
||||
// We cannot make it a pointer as the parser panics for inlined pointer structs.
|
||||
|
@ -1463,7 +1466,7 @@ type QueueConfig struct {
|
|||
|
||||
// RemoteReadConfig is the configuration for reading from remote storage.
|
||||
type RemoteReadConfig struct {
|
||||
URL *URL `yaml:"url,omitempty"`
|
||||
URL *URL `yaml:"url"`
|
||||
RemoteTimeout model.Duration `yaml:"remote_timeout,omitempty"`
|
||||
|
||||
// We cannot do proper Go type embedding below as the parser will then parse
|
||||
|
@ -1481,6 +1484,9 @@ func (c *RemoteReadConfig) UnmarshalYAML(unmarshal func(interface{}) error) erro
|
|||
if err := unmarshal((*plain)(c)); err != nil {
|
||||
return err
|
||||
}
|
||||
if c.URL == nil {
|
||||
return fmt.Errorf("url for remote_read is empty")
|
||||
}
|
||||
|
||||
// The UnmarshalYAML method of HTTPClientConfig is not being called because it's not a pointer.
|
||||
// We cannot make it a pointer as the parser panics for inlined pointer structs.
|
||||
|
|
|
@ -668,6 +668,12 @@ var expectedErrors = []struct {
|
|||
}, {
|
||||
filename: "unknown_global_attr.bad.yml",
|
||||
errMsg: "unknown fields in global config: nonexistent_field",
|
||||
}, {
|
||||
filename: "remote_read_url_missing.bad.yml",
|
||||
errMsg: `url for remote_read is empty`,
|
||||
}, {
|
||||
filename: "remote_write_url_missing.bad.yml",
|
||||
errMsg: `url for remote_write is empty`,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
2
config/testdata/remote_read_url_missing.bad.yml
vendored
Normal file
2
config/testdata/remote_read_url_missing.bad.yml
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
remote_read:
|
||||
- url:
|
2
config/testdata/remote_write_url_missing.bad.yml
vendored
Normal file
2
config/testdata/remote_write_url_missing.bad.yml
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
remote_write:
|
||||
- url:
|
Loading…
Reference in a new issue