mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-28 15:09:39 -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.
|
||||
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
|
||||
}
|
||||
// First set the correct scrape interval, then check that the timeout
|
||||
// (inferred or explicit) is not greater than that.
|
||||
if c.ScrapeInterval == 0 {
|
||||
c.ScrapeInterval = DefaultGlobalConfig.ScrapeInterval
|
||||
if gc.ScrapeInterval == 0 {
|
||||
gc.ScrapeInterval = DefaultGlobalConfig.ScrapeInterval
|
||||
}
|
||||
if c.ScrapeTimeout > c.ScrapeInterval {
|
||||
if gc.ScrapeTimeout > gc.ScrapeInterval {
|
||||
return fmt.Errorf("global scrape timeout greater than scrape interval")
|
||||
}
|
||||
if c.ScrapeTimeout == 0 {
|
||||
if DefaultGlobalConfig.ScrapeTimeout > c.ScrapeInterval {
|
||||
c.ScrapeTimeout = c.ScrapeInterval
|
||||
if gc.ScrapeTimeout == 0 {
|
||||
if DefaultGlobalConfig.ScrapeTimeout > gc.ScrapeInterval {
|
||||
gc.ScrapeTimeout = gc.ScrapeInterval
|
||||
} else {
|
||||
c.ScrapeTimeout = DefaultGlobalConfig.ScrapeTimeout
|
||||
gc.ScrapeTimeout = DefaultGlobalConfig.ScrapeTimeout
|
||||
}
|
||||
}
|
||||
if c.EvaluationInterval == 0 {
|
||||
c.EvaluationInterval = DefaultGlobalConfig.EvaluationInterval
|
||||
if gc.EvaluationInterval == 0 {
|
||||
gc.EvaluationInterval = DefaultGlobalConfig.EvaluationInterval
|
||||
}
|
||||
*c = *gc
|
||||
|
||||
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:
|
||||
scrape_timeout: 1h
|
||||
scrape_interval: 1h
|
||||
|
|
|
@ -864,6 +864,7 @@ type bintree struct {
|
|||
Func func() (*asset, error)
|
||||
Children map[string]*bintree
|
||||
}
|
||||
|
||||
var _bintree = &bintree{nil, map[string]*bintree{
|
||||
"web": &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)
|
||||
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue