mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-30 07:59:40 -08:00
Merge pull request #1392 from prometheus/scrapetimeout
Fix global config YAML issues
This commit is contained in:
commit
65d226b17a
|
@ -302,27 +302,33 @@ type GlobalConfig struct {
|
||||||
|
|
||||||
// UnmarshalYAML implements the yaml.Unmarshaler interface.
|
// UnmarshalYAML implements the yaml.Unmarshaler interface.
|
||||||
func (c *GlobalConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
func (c *GlobalConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
if err := unmarshal(c); err != nil {
|
// Create a clean global config as the previous one was already populated
|
||||||
|
// by the default due to the YAML parser behavior for empty blocks.
|
||||||
|
gc := &GlobalConfig{}
|
||||||
|
type plain GlobalConfig
|
||||||
|
if err := unmarshal((*plain)(gc)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// First set the correct scrape interval, then check that the timeout
|
// First set the correct scrape interval, then check that the timeout
|
||||||
// (inferred or explicit) is not greater than that.
|
// (inferred or explicit) is not greater than that.
|
||||||
if c.ScrapeInterval == 0 {
|
if gc.ScrapeInterval == 0 {
|
||||||
c.ScrapeInterval = DefaultGlobalConfig.ScrapeInterval
|
gc.ScrapeInterval = DefaultGlobalConfig.ScrapeInterval
|
||||||
}
|
}
|
||||||
if c.ScrapeTimeout > c.ScrapeInterval {
|
if gc.ScrapeTimeout > gc.ScrapeInterval {
|
||||||
return fmt.Errorf("global scrape timeout greater than scrape interval")
|
return fmt.Errorf("global scrape timeout greater than scrape interval")
|
||||||
}
|
}
|
||||||
if c.ScrapeTimeout == 0 {
|
if gc.ScrapeTimeout == 0 {
|
||||||
if DefaultGlobalConfig.ScrapeTimeout > c.ScrapeInterval {
|
if DefaultGlobalConfig.ScrapeTimeout > gc.ScrapeInterval {
|
||||||
c.ScrapeTimeout = c.ScrapeInterval
|
gc.ScrapeTimeout = gc.ScrapeInterval
|
||||||
} else {
|
} else {
|
||||||
c.ScrapeTimeout = DefaultGlobalConfig.ScrapeTimeout
|
gc.ScrapeTimeout = DefaultGlobalConfig.ScrapeTimeout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if c.EvaluationInterval == 0 {
|
if gc.EvaluationInterval == 0 {
|
||||||
c.EvaluationInterval = DefaultGlobalConfig.EvaluationInterval
|
gc.EvaluationInterval = DefaultGlobalConfig.EvaluationInterval
|
||||||
}
|
}
|
||||||
|
*c = *gc
|
||||||
|
|
||||||
return checkOverflow(c.XXX, "global config")
|
return checkOverflow(c.XXX, "global config")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
config/testdata/global_timeout.good.yml
vendored
1
config/testdata/global_timeout.good.yml
vendored
|
@ -1,2 +1,3 @@
|
||||||
global:
|
global:
|
||||||
scrape_timeout: 1h
|
scrape_timeout: 1h
|
||||||
|
scrape_interval: 1h
|
||||||
|
|
|
@ -864,6 +864,7 @@ type bintree struct {
|
||||||
Func func() (*asset, error)
|
Func func() (*asset, error)
|
||||||
Children map[string]*bintree
|
Children map[string]*bintree
|
||||||
}
|
}
|
||||||
|
|
||||||
var _bintree = &bintree{nil, map[string]*bintree{
|
var _bintree = &bintree{nil, map[string]*bintree{
|
||||||
"web": &bintree{nil, map[string]*bintree{
|
"web": &bintree{nil, map[string]*bintree{
|
||||||
"ui": &bintree{nil, map[string]*bintree{
|
"ui": &bintree{nil, map[string]*bintree{
|
||||||
|
@ -979,4 +980,3 @@ func _filePath(dir, name string) string {
|
||||||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||||
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue