Skip to content

Commit

Permalink
rename a few things to be consistently singular
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielc committed May 3, 2017
1 parent a31abae commit 3e8f05f
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 105 deletions.
7 changes: 4 additions & 3 deletions etc/kapacitor/kapacitor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ default-retention-policy = ""
batch-pending = 5
batch-timeout = "1s"

#[[scrapers]]
#[[scraper]]
# enabled = false
# name = "myscraper"
# discoverer-id = ""
Expand Down Expand Up @@ -533,10 +533,11 @@ default-retention-policy = ""
# refresh-interval = "1m0s"
# port = 80
#
#[[files]]
#[[file-discovery]]
# enabled = false
# id = "myfile"
# refresh-interval = "5m0s"
# files = []
#
#[[gce]]
# enabled = false
Expand Down Expand Up @@ -570,7 +571,7 @@ default-retention-policy = ""
# id = "myserverset"
# timeout = "10s"
#
#[[static]]
#[[static-discovery]]
# enabled = false
# id = "mystatic"
# targets = []
Expand Down
50 changes: 25 additions & 25 deletions server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/influxdata/kapacitor/services/deadman"
"github.com/influxdata/kapacitor/services/dns"
"github.com/influxdata/kapacitor/services/ec2"
"github.com/influxdata/kapacitor/services/file"
"github.com/influxdata/kapacitor/services/file_discovery"
"github.com/influxdata/kapacitor/services/gce"
"github.com/influxdata/kapacitor/services/hipchat"
"github.com/influxdata/kapacitor/services/httpd"
Expand All @@ -40,7 +40,7 @@ import (
"github.com/influxdata/kapacitor/services/slack"
"github.com/influxdata/kapacitor/services/smtp"
"github.com/influxdata/kapacitor/services/snmptrap"
"github.com/influxdata/kapacitor/services/static"
"github.com/influxdata/kapacitor/services/static_discovery"
"github.com/influxdata/kapacitor/services/stats"
"github.com/influxdata/kapacitor/services/storage"
"github.com/influxdata/kapacitor/services/talk"
Expand All @@ -67,10 +67,10 @@ type Config struct {
ConfigOverride config.Config `toml:"config-override"`

// Input services
Graphites []graphite.Config `toml:"graphite"`
Collectd collectd.Config `toml:"collectd"`
OpenTSDB opentsdb.Config `toml:"opentsdb"`
UDPs []udp.Config `toml:"udp"`
Graphite []graphite.Config `toml:"graphite"`
Collectd collectd.Config `toml:"collectd"`
OpenTSDB opentsdb.Config `toml:"opentsdb"`
UDP []udp.Config `toml:"udp"`

// Alert handlers
Alerta alerta.Config `toml:"alerta" override:"alerta"`
Expand All @@ -88,18 +88,18 @@ type Config struct {
VictorOps victorops.Config `toml:"victorops" override:"victorops"`

// Discovery for scraping
Scrapers []scraper.Config `toml:"scrapers" override:"scrapers,element-key=name"`
Azure []azure.Config `toml:"azure" override:"azure,element-key=id"`
Consul []consul.Config `toml:"consul" override:"consul,element-key=id"`
DNS []dns.Config `toml:"dns" override:"dns,element-key=id"`
EC2 []ec2.Config `toml:"ec2" override:"ec2,element-key=id"`
Files []file.Config `toml:"files-discovery" override:"files-discovery,element-key=id"`
GCE []gce.Config `toml:"gce" override:"gce,element-key=id"`
Marathon []marathon.Config `toml:"marathon" override:"marathon,element-key=id"`
Nerve []nerve.Config `toml:"nerve" override:"nerve,element-key=id"`
Serverset []serverset.Config `toml:"serverset" override:"serverset,element-key=id"`
Static []static.Config `toml:"static-discovery" override:"static-discovery,element-key=id"`
Triton []triton.Config `toml:"triton" override:"triton,element-key=id"`
Scraper []scraper.Config `toml:"scraper" override:"scraper,element-key=name"`
Azure []azure.Config `toml:"azure" override:"azure,element-key=id"`
Consul []consul.Config `toml:"consul" override:"consul,element-key=id"`
DNS []dns.Config `toml:"dns" override:"dns,element-key=id"`
EC2 []ec2.Config `toml:"ec2" override:"ec2,element-key=id"`
FileDiscovery []file_discovery.Config `toml:"file-discovery" override:"file-discovery,element-key=id"`
GCE []gce.Config `toml:"gce" override:"gce,element-key=id"`
Marathon []marathon.Config `toml:"marathon" override:"marathon,element-key=id"`
Nerve []nerve.Config `toml:"nerve" override:"nerve,element-key=id"`
Serverset []serverset.Config `toml:"serverset" override:"serverset,element-key=id"`
StaticDiscovery []static_discovery.Config `toml:"static-discovery" override:"static-discovery,element-key=id"`
Triton []triton.Config `toml:"triton" override:"triton,element-key=id"`

// Third-party integrations
Kubernetes k8s.Configs `toml:"kubernetes" override:"kubernetes,element-key=id"`
Expand Down Expand Up @@ -231,7 +231,7 @@ func (c *Config) Validate() error {
}

// Validate inputs
for _, g := range c.Graphites {
for _, g := range c.Graphite {
if err := g.Validate(); err != nil {
return fmt.Errorf("invalid graphite config: %v", err)
}
Expand Down Expand Up @@ -283,8 +283,8 @@ func (c *Config) Validate() error {
}

// Validate scrapers
for i := range c.Scrapers {
if err := c.Scrapers[i].Validate(); err != nil {
for i := range c.Scraper {
if err := c.Scraper[i].Validate(); err != nil {
return err
}
}
Expand Down Expand Up @@ -313,8 +313,8 @@ func (c *Config) Validate() error {
}
}

for i := range c.Files {
if err := c.Files[i].Validate(); err != nil {
for i := range c.FileDiscovery {
if err := c.FileDiscovery[i].Validate(); err != nil {
return err
}
}
Expand Down Expand Up @@ -347,8 +347,8 @@ func (c *Config) Validate() error {
}
}

for i := range c.Static {
if err := c.Static[i].Validate(); err != nil {
for i := range c.StaticDiscovery {
if err := c.StaticDiscovery[i].Validate(); err != nil {
return err
}
}
Expand Down
110 changes: 44 additions & 66 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/influxdata/kapacitor/services/deadman"
"github.com/influxdata/kapacitor/services/dns"
"github.com/influxdata/kapacitor/services/ec2"
"github.com/influxdata/kapacitor/services/file"
"github.com/influxdata/kapacitor/services/file_discovery"
"github.com/influxdata/kapacitor/services/gce"
"github.com/influxdata/kapacitor/services/hipchat"
"github.com/influxdata/kapacitor/services/httpd"
Expand All @@ -51,7 +51,7 @@ import (
"github.com/influxdata/kapacitor/services/slack"
"github.com/influxdata/kapacitor/services/smtp"
"github.com/influxdata/kapacitor/services/snmptrap"
"github.com/influxdata/kapacitor/services/static"
"github.com/influxdata/kapacitor/services/static_discovery"
"github.com/influxdata/kapacitor/services/stats"
"github.com/influxdata/kapacitor/services/storage"
"github.com/influxdata/kapacitor/services/talk"
Expand Down Expand Up @@ -103,18 +103,7 @@ type Server struct {
TesterService *servicetest.Service
StatsService *stats.Service

ScraperService *scraper.Service
AzureService *azure.Service
ConsulService *consul.Service
DNSService *dns.Service
EC2Service *ec2.Service
FileService *file.Service
GCEService *gce.Service
MarathonService *marathon.Service
NerveService *nerve.Service
ServersetService *serverset.Service
StaticService *static.Service
TritonService *triton.Service
ScraperService *scraper.Service

MetaClient *kapacitor.NoopMetaClient
QueryExecutor *Queryexecutor
Expand Down Expand Up @@ -251,21 +240,21 @@ func New(c *Config, buildInfo BuildInfo, logService logging.Interface) (*Server,
// Append Scraper and discovery services
s.appendScraperService()

if err := s.appendK8sService(s.ScraperService); err != nil {
if err := s.appendK8sService(); err != nil {
return nil, errors.Wrap(err, "kubernetes service")
}

s.appendAzureService(s.ScraperService)
s.appendConsulService(s.ScraperService)
s.appendDNSService(s.ScraperService)
s.appendEC2Service(s.ScraperService)
s.appendFileService(s.ScraperService)
s.appendGCEService(s.ScraperService)
s.appendMarathonService(s.ScraperService)
s.appendNerveService(s.ScraperService)
s.appendServersetService(s.ScraperService)
s.appendStaticService(s.ScraperService)
s.appendTritonService(s.ScraperService)
s.appendAzureService()
s.appendConsulService()
s.appendDNSService()
s.appendEC2Service()
s.appendFileService()
s.appendGCEService()
s.appendMarathonService()
s.appendNerveService()
s.appendServersetService()
s.appendStaticService()
s.appendTritonService()

// Append HTTPD Service last so that the API is not listening till everything else succeeded.
s.appendHTTPDService()
Expand Down Expand Up @@ -416,10 +405,10 @@ func (s *Server) appendReplayService() {
s.AppendService("replay", srv)
}

func (s *Server) appendK8sService(r scraper.Registry) error {
func (s *Server) appendK8sService() error {
c := s.config.Kubernetes
l := s.LogService.NewLogger("[kubernetes] ", log.LstdFlags)
srv, err := k8s.NewService(c, r, l)
srv, err := k8s.NewService(c, s.ScraperService, l)
if err != nil {
return err
}
Expand Down Expand Up @@ -637,7 +626,7 @@ func (s *Server) appendOpenTSDBService() error {
}

func (s *Server) appendGraphiteServices() error {
for i, c := range s.config.Graphites {
for i, c := range s.config.Graphite {
if !c.Enabled {
continue
}
Expand All @@ -656,7 +645,7 @@ func (s *Server) appendGraphiteServices() error {
}

func (s *Server) appendUDPServices() {
for i, c := range s.config.UDPs {
for i, c := range s.config.UDP {
if !c.Enabled {
continue
}
Expand Down Expand Up @@ -691,7 +680,7 @@ func (s *Server) appendReportingService() {
}

func (s *Server) appendScraperService() {
c := s.config.Scrapers
c := s.config.Scraper
l := s.LogService.NewLogger("[scrapers] ", log.LstdFlags)
srv := scraper.NewService(c, l)
srv.PointsWriter = s.TaskMaster
Expand All @@ -700,101 +689,90 @@ func (s *Server) appendScraperService() {
s.AppendService("scrapers", srv)
}

func (s *Server) appendAzureService(r scraper.Registry) {
func (s *Server) appendAzureService() {
c := s.config.Azure
l := s.LogService.NewLogger("[azure] ", log.LstdFlags)
srv := azure.NewService(c, r, l)
s.AzureService = srv
srv := azure.NewService(c, s.ScraperService, l)
s.SetDynamicService("azure", srv)
s.AppendService("azure", srv)
}

func (s *Server) appendConsulService(r scraper.Registry) {
func (s *Server) appendConsulService() {
c := s.config.Consul
l := s.LogService.NewLogger("[consul] ", log.LstdFlags)
srv := consul.NewService(c, r, l)
s.ConsulService = srv
srv := consul.NewService(c, s.ScraperService, l)
s.SetDynamicService("consul", srv)
s.AppendService("consul", srv)
}

func (s *Server) appendDNSService(r scraper.Registry) {
func (s *Server) appendDNSService() {
c := s.config.DNS
l := s.LogService.NewLogger("[dns] ", log.LstdFlags)
srv := dns.NewService(c, r, l)
s.DNSService = srv
srv := dns.NewService(c, s.ScraperService, l)
s.SetDynamicService("dns", srv)
s.AppendService("dns", srv)
}

func (s *Server) appendEC2Service(r scraper.Registry) {
func (s *Server) appendEC2Service() {
c := s.config.EC2
l := s.LogService.NewLogger("[ec2] ", log.LstdFlags)
srv := ec2.NewService(c, r, l)
s.EC2Service = srv
srv := ec2.NewService(c, s.ScraperService, l)
s.SetDynamicService("ec2", srv)
s.AppendService("ec2", srv)
}

func (s *Server) appendFileService(r scraper.Registry) {
c := s.config.Files
func (s *Server) appendFileService() {
c := s.config.FileDiscovery
l := s.LogService.NewLogger("[files-discovery] ", log.LstdFlags)
srv := file.NewService(c, r, l)
s.FileService = srv
srv := file_discovery.NewService(c, s.ScraperService, l)
s.SetDynamicService("files-discovery", srv)
s.AppendService("files-discovery", srv)
}

func (s *Server) appendGCEService(r scraper.Registry) {
func (s *Server) appendGCEService() {
c := s.config.GCE
l := s.LogService.NewLogger("[gce] ", log.LstdFlags)
srv := gce.NewService(c, r, l)
s.GCEService = srv
srv := gce.NewService(c, s.ScraperService, l)
s.SetDynamicService("gce", srv)
s.AppendService("gce", srv)
}

func (s *Server) appendMarathonService(r scraper.Registry) {
func (s *Server) appendMarathonService() {
c := s.config.Marathon
l := s.LogService.NewLogger("[marathon] ", log.LstdFlags)
srv := marathon.NewService(c, r, l)
s.MarathonService = srv
srv := marathon.NewService(c, s.ScraperService, l)
s.SetDynamicService("marathon", srv)
s.AppendService("marathon", srv)
}

func (s *Server) appendNerveService(r scraper.Registry) {
func (s *Server) appendNerveService() {
c := s.config.Nerve
l := s.LogService.NewLogger("[nerve] ", log.LstdFlags)
srv := nerve.NewService(c, r, l)
s.NerveService = srv
srv := nerve.NewService(c, s.ScraperService, l)
s.SetDynamicService("nerve", srv)
s.AppendService("nerve", srv)
}

func (s *Server) appendServersetService(r scraper.Registry) {
func (s *Server) appendServersetService() {
c := s.config.Serverset
l := s.LogService.NewLogger("[serverset] ", log.LstdFlags)
srv := serverset.NewService(c, r, l)
s.ServersetService = srv
srv := serverset.NewService(c, s.ScraperService, l)
s.SetDynamicService("serverset", srv)
s.AppendService("serverset", srv)
}

func (s *Server) appendStaticService(r scraper.Registry) {
c := s.config.Static
func (s *Server) appendStaticService() {
c := s.config.StaticDiscovery
l := s.LogService.NewLogger("[static-discovery] ", log.LstdFlags)
srv := static.NewService(c, r, l)
s.StaticService = srv
srv := static_discovery.NewService(c, s.ScraperService, l)
s.SetDynamicService("static-discovery", srv)
s.AppendService("static-discovery", srv)
}

func (s *Server) appendTritonService(r scraper.Registry) {
func (s *Server) appendTritonService() {
c := s.config.Triton
l := s.LogService.NewLogger("[triton] ", log.LstdFlags)
srv := triton.NewService(c, r, l)
s.TritonService = srv
srv := triton.NewService(c, s.ScraperService, l)
s.SetDynamicService("triton", srv)
s.AppendService("triton", srv)
}
Expand Down
Loading

0 comments on commit 3e8f05f

Please sign in to comment.