Skip to content

Commit

Permalink
Improve event normalization performance (#22974)
Browse files Browse the repository at this point in the history
Co-authored-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
  • Loading branch information
newly12 and jsoriano authored Dec 9, 2020
1 parent 374ef1f commit d9d337c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Update k8s client and release k8s leader lock gracefully {pull}22919[22919]
- 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]
- Add tini as init system in docker images {pull}22137[22137]

*Auditbeat*
Expand Down
14 changes: 14 additions & 0 deletions libbeat/publisher/processing/default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion libbeat/publisher/processing/processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit d9d337c

Please sign in to comment.