From dff7cc1d689ef0c9e1f2ac2bdd244f02e1aea427 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Mon, 1 May 2017 14:20:10 -0500 Subject: [PATCH 1/3] Update files and static to files-discovery and static-discovery --- server/config.go | 4 ++-- server/server.go | 12 ++++++------ services/file/config.go | 2 +- services/scraper/service.go | 9 ++++++++- services/static/config.go | 4 ++-- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/server/config.go b/server/config.go index 035781ae7..8b353d108 100644 --- a/server/config.go +++ b/server/config.go @@ -91,12 +91,12 @@ type Config struct { 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" override:"files,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" override:"static,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"` // Third-party integrations diff --git a/server/server.go b/server/server.go index fef0e8021..b08426e1b 100644 --- a/server/server.go +++ b/server/server.go @@ -723,11 +723,11 @@ func (s *Server) appendEC2Service(r scraper.Registry) { func (s *Server) appendFileService(r scraper.Registry) { c := s.config.Files - l := s.LogService.NewLogger("[files] ", log.LstdFlags) + l := s.LogService.NewLogger("[files-discovery] ", log.LstdFlags) srv := file.NewService(c, r, l) s.FileService = srv - s.SetDynamicService("files", srv) - s.AppendService("files", srv) + s.SetDynamicService("files-discovery", srv) + s.AppendService("files-discovery", srv) } func (s *Server) appendGCEService(r scraper.Registry) { @@ -768,11 +768,11 @@ func (s *Server) appendServersetService(r scraper.Registry) { func (s *Server) appendStaticService(r scraper.Registry) { c := s.config.Static - l := s.LogService.NewLogger("[static] ", log.LstdFlags) + l := s.LogService.NewLogger("[static-discovery] ", log.LstdFlags) srv := static.NewService(c, r, l) s.StaticService = srv - s.SetDynamicService("static", srv) - s.AppendService("static", srv) + s.SetDynamicService("static-discovery", srv) + s.AppendService("static-discovery", srv) } func (s *Server) appendTritonService(r scraper.Registry) { diff --git a/services/file/config.go b/services/file/config.go index 3f88a4732..a38ba070a 100644 --- a/services/file/config.go +++ b/services/file/config.go @@ -56,7 +56,7 @@ func (f Config) PromConfig() *config.FileSDConfig { // Service return discoverer type func (f Config) Service() string { - return "files" + return "files-discovery" } // ServiceID returns the discoverers name diff --git a/services/scraper/service.go b/services/scraper/service.go index 33c07e47b..c3f6ab5d2 100644 --- a/services/scraper/service.go +++ b/services/scraper/service.go @@ -3,6 +3,7 @@ package scraper import ( "fmt" "log" + "math" "sync" "github.com/influxdata/influxdb/models" @@ -118,6 +119,12 @@ func (s *Service) scrape() { // Append tranforms prometheus samples and inserts data into the tasks pipeline func (s *Service) Append(sample *model.Sample) error { + value := float64(sample.Value) + // Remove all NaN values + if math.IsNaN(value) { + return nil + } + var err error db := "" rp := "" @@ -154,7 +161,7 @@ func (s *Service) Append(sample *model.Sample) error { } fields := models.Fields{ - "value": float64(sample.Value), + "value": value, } pt, err := models.NewPoint(job, models.NewTags(tags), fields, sample.Timestamp.Time()) diff --git a/services/static/config.go b/services/static/config.go index 60a2c47be..1a95ebef7 100644 --- a/services/static/config.go +++ b/services/static/config.go @@ -27,7 +27,7 @@ func (s *Config) Init() { // Validate validates Static configuration values func (s Config) Validate() error { if s.ID == "" { - return fmt.Errorf("azure discovery must be given a ID") + return fmt.Errorf("static discovery must be given a ID") } return nil } @@ -64,7 +64,7 @@ func (s Config) PromConfig() []*config.TargetGroup { // Service return discoverer type func (s Config) Service() string { - return "static" + return "static-discovery" } // ServiceID returns the discoverers name From e678136c89186c2c38b7898deb0096a501984ea1 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Mon, 1 May 2017 15:02:50 -0500 Subject: [PATCH 2/3] Fix server tests for files-discovery and static-discovery --- server/server_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/server_test.go b/server/server_test.go index 2a51249dd..09bfb1048 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -7086,8 +7086,8 @@ func TestServer_ListServiceTests(t *testing.T) { }, }, { - Link: client.Link{Relation: "self", Href: "/kapacitor/v1/service-tests/files"}, - Name: "files", + Link: client.Link{Relation: "self", Href: "/kapacitor/v1/service-tests/files-discovery"}, + Name: "files-discovery", Options: client.ServiceTestOptions{ "id": "", }, @@ -7229,8 +7229,8 @@ func TestServer_ListServiceTests(t *testing.T) { }, }, { - Link: client.Link{Relation: "self", Href: "/kapacitor/v1/service-tests/static"}, - Name: "static", + Link: client.Link{Relation: "self", Href: "/kapacitor/v1/service-tests/static-discovery"}, + Name: "static-discovery", Options: client.ServiceTestOptions{ "id": "", }, @@ -7359,8 +7359,8 @@ func TestServer_ListServiceTests_WithPattern(t *testing.T) { }, }, { - Link: client.Link{Relation: "self", Href: "/kapacitor/v1/service-tests/static"}, - Name: "static", + Link: client.Link{Relation: "self", Href: "/kapacitor/v1/service-tests/static-discovery"}, + Name: "static-discovery", Options: client.ServiceTestOptions{ "id": "", }, From c6d5d2c107a33ac6c6b1245ba5e4a70699f75c3b Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Mon, 1 May 2017 15:03:14 -0500 Subject: [PATCH 3/3] Add comment about tracking isNaN --- services/scraper/service.go | 1 + 1 file changed, 1 insertion(+) diff --git a/services/scraper/service.go b/services/scraper/service.go index c3f6ab5d2..3757e589b 100644 --- a/services/scraper/service.go +++ b/services/scraper/service.go @@ -121,6 +121,7 @@ func (s *Service) scrape() { func (s *Service) Append(sample *model.Sample) error { value := float64(sample.Value) // Remove all NaN values + // TODO: Add counter stat for this variable if math.IsNaN(value) { return nil }