Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve event normalization performance #22974

Merged
merged 3 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
- 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