Merge pull request #1048 from xperimental/fix/marathon-config
Fix parsing Marathon SD config
This commit is contained in:
commit
1ef5ed0cf2
|
@ -626,6 +626,10 @@ type KubernetesSDConfig struct {
|
||||||
func (c *MarathonSDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
func (c *MarathonSDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||||
*c = DefaultMarathonSDConfig
|
*c = DefaultMarathonSDConfig
|
||||||
type plain MarathonSDConfig
|
type plain MarathonSDConfig
|
||||||
|
err := unmarshal((*plain)(c))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if len(c.Servers) == 0 {
|
if len(c.Servers) == 0 {
|
||||||
return fmt.Errorf("Marathon SD config must contain at least one Marathon server")
|
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: "",
|
original: "",
|
||||||
}
|
}
|
||||||
|
@ -281,6 +299,9 @@ var expectedErrors = []struct {
|
||||||
}, {
|
}, {
|
||||||
filename: "bearertoken_basicauth.bad.yml",
|
filename: "bearertoken_basicauth.bad.yml",
|
||||||
errMsg: "at most one of basic_auth, bearer_token & bearer_token_file must be configured",
|
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",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,3 +107,8 @@ scrape_configs:
|
||||||
- 'https://localhost:1234'
|
- 'https://localhost:1234'
|
||||||
username: 'myusername'
|
username: 'myusername'
|
||||||
password: 'mypassword'
|
password: 'mypassword'
|
||||||
|
|
||||||
|
- job_name: service-marathon
|
||||||
|
marathon_sd_configs:
|
||||||
|
- servers:
|
||||||
|
- 'http://marathon.example.com:8080'
|
||||||
|
|
|
@ -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 New Issue