mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
Merge pull request #990 from prometheus/fabxc/allconsul
Scrape all services on empty services list.
This commit is contained in:
commit
d8f5da9152
|
@ -529,6 +529,7 @@ type ConsulSDConfig struct {
|
|||
Username string `yaml:"username,omitempty"`
|
||||
Password string `yaml:"password,omitempty"`
|
||||
// The list of services for which targets are discovered.
|
||||
// Defaults to all services if empty.
|
||||
Services []string `yaml:"services"`
|
||||
|
||||
// Catches all undefined fields and must be empty after parsing.
|
||||
|
@ -546,9 +547,6 @@ func (c *ConsulSDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
|
|||
if strings.TrimSpace(c.Server) == "" {
|
||||
return fmt.Errorf("Consul SD configuration requires a server address")
|
||||
}
|
||||
if len(c.Services) == 0 {
|
||||
return fmt.Errorf("Consul SD configuration requires at least one service name")
|
||||
}
|
||||
return checkOverflow(c.XXX, "consul_sd_config")
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ func (cd *ConsulDiscovery) Sources() []string {
|
|||
|
||||
srcs := make([]string, 0, len(srvs))
|
||||
for name := range srvs {
|
||||
if _, ok := cd.scrapedServices[name]; ok {
|
||||
if _, ok := cd.scrapedServices[name]; len(cd.scrapedServices) == 0 || ok {
|
||||
srcs = append(srcs, name)
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ func (cd *ConsulDiscovery) watchServices(update chan<- *consulService, done <-ch
|
|||
}
|
||||
// Check for new services.
|
||||
for name := range srvs {
|
||||
if _, ok := cd.scrapedServices[name]; !ok {
|
||||
if _, ok := cd.scrapedServices[name]; len(cd.scrapedServices) > 0 && !ok {
|
||||
continue
|
||||
}
|
||||
srv, ok := cd.services[name]
|
||||
|
|
Loading…
Reference in a new issue