From 048448aa93cf9dcfd3ce80fa1edd3903f7f9ea91 Mon Sep 17 00:00:00 2001 From: Rene Zbinden Date: Sat, 25 Jun 2016 12:17:51 +0200 Subject: [PATCH 1/2] add build directory to git ignore (#1415) --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7d27d694e..8269337df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +build tivan .vagrant /telegraf From 2d4864e126c5e72dec8ec0be15f8bb396de8840b Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Wed, 29 Jun 2016 11:58:31 +0200 Subject: [PATCH 2/2] nil metric list panic fix --- CHANGELOG.md | 1 + internal/models/running_output.go | 2 +- plugins/serializers/graphite/graphite.go | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f614f4422..3f130fe60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ should now look like: ### Bugfixes +- [#1426](https://github.com/influxdata/telegraf/pull/1426): nil metrics panic fix. - [#1384](https://github.com/influxdata/telegraf/pull/1384): Fix datarace in apache input plugin. - [#1399](https://github.com/influxdata/telegraf/issues/1399): Add `read_repairs` statistics to riak plugin. - [#1405](https://github.com/influxdata/telegraf/issues/1405): Fix memory/connection leak in prometheus input plugin. diff --git a/internal/models/running_output.go b/internal/models/running_output.go index d0d2abbc1..42025912c 100644 --- a/internal/models/running_output.go +++ b/internal/models/running_output.go @@ -138,7 +138,7 @@ func (ro *RunningOutput) Write() error { } func (ro *RunningOutput) write(metrics []telegraf.Metric) error { - if len(metrics) == 0 { + if metrics == nil || len(metrics) == 0 { return nil } start := time.Now() diff --git a/plugins/serializers/graphite/graphite.go b/plugins/serializers/graphite/graphite.go index bf2e75579..43e32c244 100644 --- a/plugins/serializers/graphite/graphite.go +++ b/plugins/serializers/graphite/graphite.go @@ -26,6 +26,9 @@ func (s *GraphiteSerializer) Serialize(metric telegraf.Metric) ([]string, error) timestamp := metric.UnixNano() / 1000000000 bucket := s.SerializeBucketName(metric.Name(), metric.Tags()) + if bucket == "" { + return out, nil + } for fieldName, value := range metric.Fields() { // Convert value to string @@ -89,6 +92,10 @@ func (s *GraphiteSerializer) SerializeBucketName( } } + if len(out) == 0 { + return "" + } + if s.Prefix == "" { return sanitizedChars.Replace(strings.Join(out, ".")) }