From 12db3b91208415364cc1649844e77143a1221a1f Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Tue, 13 Dec 2016 12:24:39 +0000 Subject: [PATCH] Check if metric is nil before calling SetAggregate fixes #2146 --- CHANGELOG.md | 3 ++- internal/models/running_aggregator.go | 4 +++- plugins/inputs/logparser/README.md | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3d3ef5f5..6f5ca5d3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,8 @@ - [#2049](https://github.com/influxdata/telegraf/pull/2049): Fix the Value data format not trimming null characters from input. - [#1949](https://github.com/influxdata/telegraf/issues/1949): Fix windows `net` plugin. -- [#1775](https://github.com/influxdata/telegraf/issues/1775): Cache & expire metrics for delivery to prometheus +- [#1775](https://github.com/influxdata/telegraf/issues/1775): Cache & expire metrics for delivery to prometheus. +- [#2146](https://github.com/influxdata/telegraf/issues/2146): Fix potential panic in aggregator plugin metric maker. ## v1.1.2 [2016-12-12] diff --git a/internal/models/running_aggregator.go b/internal/models/running_aggregator.go index 2e22f1569..8189a6667 100644 --- a/internal/models/running_aggregator.go +++ b/internal/models/running_aggregator.go @@ -70,7 +70,9 @@ func (r *RunningAggregator) MakeMetric( t, ) - m.SetAggregate(true) + if m != nil { + m.SetAggregate(true) + } return m } diff --git a/plugins/inputs/logparser/README.md b/plugins/inputs/logparser/README.md index 1affcd811..5973d9f42 100644 --- a/plugins/inputs/logparser/README.md +++ b/plugins/inputs/logparser/README.md @@ -40,8 +40,11 @@ regex patterns. ## Grok Parser The grok parser uses a slightly modified version of logstash "grok" patterns, -with the format `%{[:][:]}` +with the format +``` +%{[:][:]} +``` Telegraf has many of it's own [built-in patterns](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/logparser/grok/patterns/influx-patterns), @@ -92,4 +95,3 @@ Timestamp modifiers can be used to convert captures to the timestamp of the CUSTOM time layouts must be within quotes and be the representation of the "reference time", which is `Mon Jan 2 15:04:05 -0700 MST 2006` See https://golang.org/pkg/time/#Parse for more details. -