diff --git a/libbeat/reader/message.go b/libbeat/reader/message.go index 0eae606f80b..e8bd1202729 100644 --- a/libbeat/reader/message.go +++ b/libbeat/reader/message.go @@ -93,5 +93,6 @@ func (m *Message) ToEvent() beat.Event { Timestamp: m.Ts, Meta: m.Meta, Fields: m.Fields, + Private: m.Private, } } diff --git a/libbeat/reader/message_test.go b/libbeat/reader/message_test.go index c73576c4767..95891724719 100644 --- a/libbeat/reader/message_test.go +++ b/libbeat/reader/message_test.go @@ -19,6 +19,7 @@ package reader import ( "testing" + "time" "github.com/stretchr/testify/require" @@ -55,6 +56,20 @@ func TestToEvent(t *testing.T) { Message{Content: []byte("my message"), Fields: common.MapStr{"my_field": "my_value"}, Meta: common.MapStr{"meta": "id"}}, beat.Event{Fields: common.MapStr{"message": "my message", "my_field": "my_value"}, Meta: common.MapStr{"meta": "id"}}, }, + "content, meta, message and private fields": { + Message{ + Ts: time.Date(2022, 1, 9, 10, 42, 0, 0, time.UTC), + Content: []byte("my message"), + Meta: common.MapStr{"foo": "bar"}, + Private: 42, + }, + beat.Event{ + Timestamp: time.Date(2022, 1, 9, 10, 42, 0, 0, time.UTC), + Fields: common.MapStr{"message": "my message"}, + Meta: common.MapStr{"foo": "bar"}, + Private: 42, + }, + }, } for name, test := range testCases {