From c023ffe0a5800865b723ded149cd72ee63427045 Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Tue, 26 Feb 2019 18:04:45 -0800 Subject: [PATCH] Add unique_timestamp option from grok parser to logparser grok --- plugins/inputs/logparser/logparser.go | 7 ++++++- plugins/parsers/grok/README.md | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/inputs/logparser/logparser.go b/plugins/inputs/logparser/logparser.go index eb23e2b74..a7fd97e8e 100644 --- a/plugins/inputs/logparser/logparser.go +++ b/plugins/inputs/logparser/logparser.go @@ -8,7 +8,6 @@ import ( "sync" "github.com/influxdata/tail" - "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/internal/globpath" "github.com/influxdata/telegraf/plugins/inputs" @@ -28,6 +27,7 @@ type GrokConfig struct { CustomPatterns string CustomPatternFiles []string Timezone string + UniqueTimestamp string } type logEntry struct { @@ -100,6 +100,10 @@ const sampleConfig = ` ## 2. "Canada/Eastern" -- Unix TZ values like those found in https://en.wikipedia.org/wiki/List_of_tz_database_time_zones ## 3. UTC -- or blank/unspecified, will return timestamp in UTC # timezone = "Canada/Eastern" + + ## When set to "disable", timestamp will not incremented if there is a + ## duplicate. + # unique_timestamp = "auto" ` // SampleConfig returns the sample configuration for the plugin @@ -144,6 +148,7 @@ func (l *LogParserPlugin) Start(acc telegraf.Accumulator) error { GrokCustomPatterns: l.GrokConfig.CustomPatterns, GrokCustomPatternFiles: l.GrokConfig.CustomPatternFiles, GrokTimezone: l.GrokConfig.Timezone, + GrokUniqueTimestamp: l.GrokConfig.UniqueTimestamp, DataFormat: "grok", } diff --git a/plugins/parsers/grok/README.md b/plugins/parsers/grok/README.md index 1570bfb28..a694735de 100644 --- a/plugins/parsers/grok/README.md +++ b/plugins/parsers/grok/README.md @@ -111,7 +111,8 @@ you will find the https://grokdebug.herokuapp.com application quite useful! ## 3. UTC -- or blank/unspecified, will return timestamp in UTC grok_timezone = "Canada/Eastern" - ## When grok_unique_timestamp is set to "disable", timestamp will not incremented if there is a duplicate. Default is "auto" + ## When set to "disable" timestamp will not incremented if there is a + ## duplicate. # grok_unique_timestamp = "auto" ```