Skip to content

Commit

Permalink
Merge pull request #4790 from influxdb/control_opentsdb_error_logs
Browse files Browse the repository at this point in the history
Allow openTSDB point errors logging to be disabled
  • Loading branch information
otoolep committed Nov 13, 2015
2 parents fa557a1 + 7ea9b3e commit b924bcd
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions etc/config.sample.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions services/opentsdb/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -53,5 +54,6 @@ func NewConfig() Config {
BatchSize: DefaultBatchSize,
BatchPending: DefaultBatchPending,
BatchTimeout: toml.Duration(DefaultBatchTimeout),
LogPointErrors: true,
}
}
3 changes: 3 additions & 0 deletions services/opentsdb/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
}
30 changes: 22 additions & 8 deletions services/opentsdb/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}

Expand All @@ -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) {
Expand All @@ -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
}

Expand All @@ -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]
Expand All @@ -330,15 +340,19 @@ 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

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
Expand Down

0 comments on commit b924bcd

Please sign in to comment.