mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-14 17:44:06 -08:00
Fix missing unmarshal for Marathon SD config.
This commit is contained in:
parent
852dfd99e2
commit
847072514e
|
@ -626,6 +626,10 @@ type KubernetesSDConfig struct {
|
|||
func (c *MarathonSDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
*c = DefaultMarathonSDConfig
|
||||
type plain MarathonSDConfig
|
||||
err := unmarshal((*plain)(c))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(c.Servers) == 0 {
|
||||
return fmt.Errorf("Marathon SD config must contain at least one Marathon server")
|
||||
}
|
||||
|
|
|
@ -206,6 +206,24 @@ var expectedConf = &Config{
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
JobName: "service-marathon",
|
||||
|
||||
ScrapeInterval: Duration(15 * time.Second),
|
||||
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
|
||||
|
||||
MetricsPath: DefaultScrapeConfig.MetricsPath,
|
||||
Scheme: DefaultScrapeConfig.Scheme,
|
||||
|
||||
MarathonSDConfigs: []*MarathonSDConfig{
|
||||
{
|
||||
Servers: []string{
|
||||
"http://marathon.example.com:8080",
|
||||
},
|
||||
RefreshInterval: Duration(30 * time.Second),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
original: "",
|
||||
}
|
||||
|
@ -281,6 +299,9 @@ var expectedErrors = []struct {
|
|||
}, {
|
||||
filename: "bearertoken_basicauth.bad.yml",
|
||||
errMsg: "at most one of basic_auth, bearer_token & bearer_token_file must be configured",
|
||||
}, {
|
||||
filename: "marathon_no_servers.bad.yml",
|
||||
errMsg: "Marathon SD config must contain at least one Marathon server",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
5
config/testdata/conf.good.yml
vendored
5
config/testdata/conf.good.yml
vendored
|
@ -107,3 +107,8 @@ scrape_configs:
|
|||
- 'https://localhost:1234'
|
||||
username: 'myusername'
|
||||
password: 'mypassword'
|
||||
|
||||
- job_name: service-marathon
|
||||
marathon_sd_configs:
|
||||
- servers:
|
||||
- 'http://marathon.example.com:8080'
|
||||
|
|
10
config/testdata/marathon_no_servers.bad.yml
vendored
Normal file
10
config/testdata/marathon_no_servers.bad.yml
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
# my global config
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 30s
|
||||
|
||||
scrape_configs:
|
||||
|
||||
- job_name: service-marathon
|
||||
marathon_sd_configs:
|
||||
- servers:
|
Loading…
Reference in a new issue