From 7ea9b3e49e04cb7fdfdfbd3569c20c59e10aea86 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Fri, 13 Nov 2015 14:53:09 -0800 Subject: [PATCH] Allow openTSDB point errors logging to be disabled --- CHANGELOG.md | 1 + etc/config.sample.toml | 1 + services/opentsdb/config.go | 2 ++ services/opentsdb/config_test.go | 3 +++ services/opentsdb/service.go | 30 ++++++++++++++++++++++-------- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 958f6b5830..438bb77401 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## v0.9.6 [unreleased] ### Features +- [#4790](https://github.com/influxdb/influxdb/pull/4790): Allow openTSDB point-level error logging to be disabled ### Bugfixes - [#4766](https://github.com/influxdb/influxdb/pull/4766): Update CLI usage output. Thanks @aneshas diff --git a/etc/config.sample.toml b/etc/config.sample.toml index e73e1ec6f3..463190a83b 100644 --- a/etc/config.sample.toml +++ b/etc/config.sample.toml @@ -277,6 +277,7 @@ reporting-disabled = false # consistency-level = "one" # tls-enabled = false # certificate= "" + # log-point-errors = true # Log an error for every malformed point. # These next lines control how batching works. You should have this enabled # otherwise you could get dropped metrics or poor performance. Only points diff --git a/services/opentsdb/config.go b/services/opentsdb/config.go index 5c17ba6758..d60c807d20 100644 --- a/services/opentsdb/config.go +++ b/services/opentsdb/config.go @@ -40,6 +40,7 @@ type Config struct { BatchSize int `toml:"batch-size"` BatchPending int `toml:"batch-pending"` BatchTimeout toml.Duration `toml:"batch-timeout"` + LogPointErrors bool `toml:"log-point-errors"` } func NewConfig() Config { @@ -53,5 +54,6 @@ func NewConfig() Config { BatchSize: DefaultBatchSize, BatchPending: DefaultBatchPending, BatchTimeout: toml.Duration(DefaultBatchTimeout), + LogPointErrors: true, } } diff --git a/services/opentsdb/config_test.go b/services/opentsdb/config_test.go index 53d9e3a80f..84bb999c4b 100644 --- a/services/opentsdb/config_test.go +++ b/services/opentsdb/config_test.go @@ -17,6 +17,7 @@ database = "xxx" consistency-level ="all" tls-enabled = true certificate = "/etc/ssl/cert.pem" +log-point-errors = true `, &c); err != nil { t.Fatal(err) } @@ -34,5 +35,7 @@ certificate = "/etc/ssl/cert.pem" t.Fatalf("unexpected tls-enabled: %v", c.TLSEnabled) } else if c.Certificate != "/etc/ssl/cert.pem" { t.Fatalf("unexpected certificate: %s", c.Certificate) + } else if !c.LogPointErrors { + t.Fatalf("unexpected log-point-errors: %v", c.LogPointErrors) } } diff --git a/services/opentsdb/service.go b/services/opentsdb/service.go index 5de12341b3..62d1c9494e 100644 --- a/services/opentsdb/service.go +++ b/services/opentsdb/service.go @@ -75,8 +75,9 @@ type Service struct { batchTimeout time.Duration batcher *tsdb.PointBatcher - Logger *log.Logger - statMap *expvar.Map + LogPointErrors bool + Logger *log.Logger + statMap *expvar.Map } // NewService returns a new instance of Service. @@ -99,6 +100,7 @@ func NewService(c Config) (*Service, error) { batchPending: c.BatchPending, batchTimeout: time.Duration(c.BatchTimeout), Logger: log.New(os.Stderr, "[opentsdb] ", log.LstdFlags), + LogPointErrors: c.LogPointErrors, } return s, nil } @@ -284,7 +286,9 @@ func (s *Service) handleTelnetConn(conn net.Conn) { if len(inputStrs) < 4 || inputStrs[0] != "put" { s.statMap.Add(statTelnetBadLine, 1) - s.Logger.Printf("malformed line '%s' from %s", line, remoteAddr) + if s.LogPointErrors { + s.Logger.Printf("malformed line '%s' from %s", line, remoteAddr) + } continue } @@ -297,7 +301,9 @@ func (s *Service) handleTelnetConn(conn net.Conn) { ts, err := strconv.ParseInt(tsStr, 10, 64) if err != nil { s.statMap.Add(statTelnetBadTime, 1) - s.Logger.Printf("malformed time '%s' from %s", tsStr, remoteAddr) + if s.LogPointErrors { + s.Logger.Printf("malformed time '%s' from %s", tsStr, remoteAddr) + } } switch len(tsStr) { @@ -309,7 +315,9 @@ func (s *Service) handleTelnetConn(conn net.Conn) { break default: s.statMap.Add(statTelnetBadTime, 1) - s.Logger.Printf("bad time '%s' must be 10 or 13 chars, from %s ", tsStr, remoteAddr) + if s.LogPointErrors { + s.Logger.Printf("bad time '%s' must be 10 or 13 chars, from %s ", tsStr, remoteAddr) + } continue } @@ -318,7 +326,9 @@ func (s *Service) handleTelnetConn(conn net.Conn) { parts := strings.SplitN(tagStrs[t], "=", 2) if len(parts) != 2 || parts[0] == "" || parts[1] == "" { s.statMap.Add(statTelnetBadTag, 1) - s.Logger.Printf("malformed tag data '%v' from %s", tagStrs[t], remoteAddr) + if s.LogPointErrors { + s.Logger.Printf("malformed tag data '%v' from %s", tagStrs[t], remoteAddr) + } continue } k := parts[0] @@ -330,7 +340,9 @@ func (s *Service) handleTelnetConn(conn net.Conn) { fv, err := strconv.ParseFloat(valueStr, 64) if err != nil { s.statMap.Add(statTelnetBadFloat, 1) - s.Logger.Printf("bad float '%s' from %s", valueStr, remoteAddr) + if s.LogPointErrors { + s.Logger.Printf("bad float '%s' from %s", valueStr, remoteAddr) + } continue } fields["value"] = fv @@ -338,7 +350,9 @@ func (s *Service) handleTelnetConn(conn net.Conn) { pt, err := models.NewPoint(measurement, tags, fields, t) if err != nil { s.statMap.Add(statTelnetBadFloat, 1) - s.Logger.Printf("bad float '%s' from %s", valueStr, remoteAddr) + if s.LogPointErrors { + s.Logger.Printf("bad float '%s' from %s", valueStr, remoteAddr) + } continue } s.batcher.In() <- pt