Skip to content

Commit

Permalink
clean up post review
Browse files Browse the repository at this point in the history
  • Loading branch information
powersj committed Jun 30, 2022
1 parent 57218e9 commit 8bc6940
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
21 changes: 9 additions & 12 deletions plugins/inputs/logparser/logparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,16 @@ func (l *LogParserPlugin) Start(acc telegraf.Accumulator) error {
}

// Looks for fields which implement LogParser interface
config := &parsers.Config{
MetricName: mName,
GrokPatterns: l.GrokConfig.Patterns,
GrokNamedPatterns: l.GrokConfig.NamedPatterns,
GrokCustomPatterns: l.GrokConfig.CustomPatterns,
GrokCustomPatternFiles: l.GrokConfig.CustomPatternFiles,
GrokTimezone: l.GrokConfig.Timezone,
GrokUniqueTimestamp: l.GrokConfig.UniqueTimestamp,
DataFormat: "grok",
parser := grok.Parser{
Measurement: mName,
Patterns: l.GrokConfig.Patterns,
NamedPatterns: l.GrokConfig.NamedPatterns,
CustomPatterns: l.GrokConfig.CustomPatterns,
CustomPatternFiles: l.GrokConfig.CustomPatternFiles,
Timezone: l.GrokConfig.Timezone,
UniqueTimestamp: l.GrokConfig.UniqueTimestamp,
}

parser := grok.Parser{}
err := parser.InitFromConfig(config)
err := parser.Init()
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/inputs/logparser/logparser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestStartNoParsers(t *testing.T) {
}

acc := testutil.Accumulator{}
require.Error(t, logparser.Start(&acc))
require.NoError(t, logparser.Start(&acc))
}

func TestGrokParseLogFilesNonExistPattern(t *testing.T) {
Expand Down

0 comments on commit 8bc6940

Please sign in to comment.