diff --git a/config/config.go b/config/config.go index 94efe33ca..775de45d4 100644 --- a/config/config.go +++ b/config/config.go @@ -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") } diff --git a/config/config_test.go b/config/config_test.go index 14161637e..0447c0ff9 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -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", }, } diff --git a/config/testdata/conf.good.yml b/config/testdata/conf.good.yml index 7725950ee..ae20b69e6 100644 --- a/config/testdata/conf.good.yml +++ b/config/testdata/conf.good.yml @@ -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' diff --git a/config/testdata/marathon_no_servers.bad.yml b/config/testdata/marathon_no_servers.bad.yml new file mode 100644 index 000000000..df245e91b --- /dev/null +++ b/config/testdata/marathon_no_servers.bad.yml @@ -0,0 +1,10 @@ +# my global config +global: + scrape_interval: 15s + evaluation_interval: 30s + +scrape_configs: + +- job_name: service-marathon + marathon_sd_configs: + - servers: