From 989a1fddeab556a36e65d10df1d3230d3606d80f Mon Sep 17 00:00:00 2001 From: Peter Deng Date: Tue, 8 Dec 2020 11:05:17 +0800 Subject: [PATCH 1/2] Improve event normalization performance --- libbeat/publisher/processing/default_test.go | 14 ++++++++++++++ libbeat/publisher/processing/processors.go | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libbeat/publisher/processing/default_test.go b/libbeat/publisher/processing/default_test.go index 637b38cf44d..ca2e740afd9 100644 --- a/libbeat/publisher/processing/default_test.go +++ b/libbeat/publisher/processing/default_test.go @@ -325,6 +325,20 @@ func TestNormalization(t *testing.T) { } } +func BenchmarkNormalization(b *testing.B) { + s, err := MakeDefaultSupport(true)(beat.Info{}, logp.L(), common.NewConfig()) + require.NoError(b, err) + + prog, err := s.Create(beat.ProcessingConfig{}, false) + require.NoError(b, err) + + fields := common.MapStr{"a": "b"} + for i := 0; i < b.N; i++ { + f := fields.Clone() + _, _ = prog.Run(&beat.Event{Fields: f}) + } +} + func TestAlwaysDrop(t *testing.T) { s, err := MakeDefaultSupport(true)(beat.Info{}, logp.L(), common.NewConfig()) require.NoError(t, err) diff --git a/libbeat/publisher/processing/processors.go b/libbeat/publisher/processing/processors.go index 3a400d36dad..19111b6aff9 100644 --- a/libbeat/publisher/processing/processors.go +++ b/libbeat/publisher/processing/processors.go @@ -44,13 +44,13 @@ type processorFn struct { func newGeneralizeProcessor(keepNull bool) *processorFn { logger := logp.NewLogger("publisher_processing") + g := common.NewGenericEventConverter(keepNull) return newProcessor("generalizeEvent", func(event *beat.Event) (*beat.Event, error) { // Filter out empty events. Empty events are still reported by ACK callbacks. if len(event.Fields) == 0 { return nil, nil } - g := common.NewGenericEventConverter(keepNull) fields := g.Convert(event.Fields) if fields == nil { logger.Error("fail to convert to generic event") From cd9a2d91bf4c7847277ee2e619ad656ac4af5b10 Mon Sep 17 00:00:00 2001 From: Peter Deng Date: Tue, 8 Dec 2020 11:38:00 +0800 Subject: [PATCH 2/2] update CHANGELOG.next.asciidoc --- CHANGELOG.next.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 819fd57d2c1..59af0c60262 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -541,6 +541,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Fix polling node when it is not ready and monitor by hostname {pull}22666[22666] - Improve equals check. {pull}22778[22778] - Added "detect_mime_type" processor for detecting mime types {pull}22940[22940] +- Improve event normalization performance {pull}22974[22974] *Auditbeat*