Allow grok pattern to contain newlines (#4005)
(cherry picked from commit 55cfc383f3
)
This commit is contained in:
parent
71948a8f84
commit
787fca496f
|
@ -132,6 +132,7 @@ func (p *Parser) Compile() error {
|
|||
// "custom patterns"
|
||||
p.namedPatterns = make([]string, 0, len(p.Patterns))
|
||||
for i, pattern := range p.Patterns {
|
||||
pattern = strings.TrimSpace(pattern)
|
||||
if pattern == "" {
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -958,3 +958,15 @@ func TestTimezoneLocalCompileFileAndParse(t *testing.T) {
|
|||
assert.Equal(t, map[string]string{}, metricB.Tags())
|
||||
assert.Equal(t, time.Date(2016, time.June, 4, 12, 41, 45, 0, time.Local).UnixNano(), metricB.Time().UnixNano())
|
||||
}
|
||||
|
||||
func TestNewlineInPatterns(t *testing.T) {
|
||||
p := &Parser{
|
||||
Patterns: []string{`
|
||||
%{SYSLOGTIMESTAMP:timestamp}
|
||||
`},
|
||||
}
|
||||
require.NoError(t, p.Compile())
|
||||
m, err := p.ParseLine("Apr 10 05:11:57")
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, m)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue