mirror of https://github.com/prometheus/prometheus
Merge pull request #1384 from prometheus/scraperef
Restrict scrape timeout to interval lengthpull/1366/merge
commit
738e6f41d4
|
@ -266,6 +266,9 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
if scfg.ScrapeTimeout == 0 {
|
if scfg.ScrapeTimeout == 0 {
|
||||||
scfg.ScrapeTimeout = c.GlobalConfig.ScrapeTimeout
|
scfg.ScrapeTimeout = c.GlobalConfig.ScrapeTimeout
|
||||||
}
|
}
|
||||||
|
if scfg.ScrapeTimeout > scfg.ScrapeInterval {
|
||||||
|
return fmt.Errorf("scrape timeout greater than scrape interval for scrape config with job name %q", scfg.JobName)
|
||||||
|
}
|
||||||
|
|
||||||
if _, ok := jobNames[scfg.JobName]; ok {
|
if _, ok := jobNames[scfg.JobName]; ok {
|
||||||
return fmt.Errorf("found multiple scrape configs with job name %q", scfg.JobName)
|
return fmt.Errorf("found multiple scrape configs with job name %q", scfg.JobName)
|
||||||
|
|
|
@ -335,6 +335,9 @@ var expectedErrors = []struct {
|
||||||
}, {
|
}, {
|
||||||
filename: "jobname_dup.bad.yml",
|
filename: "jobname_dup.bad.yml",
|
||||||
errMsg: `found multiple scrape configs with job name "prometheus"`,
|
errMsg: `found multiple scrape configs with job name "prometheus"`,
|
||||||
|
}, {
|
||||||
|
filename: "scrape_interval.bad.yml",
|
||||||
|
errMsg: `scrape timeout greater than scrape interval`,
|
||||||
}, {
|
}, {
|
||||||
filename: "labelname.bad.yml",
|
filename: "labelname.bad.yml",
|
||||||
errMsg: `"not$allowed" is not a valid label name`,
|
errMsg: `"not$allowed" is not a valid label name`,
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
scrape_configs:
|
||||||
|
- job_name: prometheus
|
||||||
|
scrape_interval: 5s
|
||||||
|
scrape_timeout: 6s
|
Loading…
Reference in New Issue