-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick #11141 to 7.0: Extract all the fields for a Kinesis Recor…
…d and not just the metadata (#11157) Cherry-pick of PR #11141 to 7.0 branch. Original message: Add data field which contains raw data of the events and information about the partition, the sequence and the schema. Add a test to ensure the tranformation is OK from a KinesisRecord to a beat.Event.
- Loading branch information
Showing
3 changed files
with
69 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
x-pack/functionbeat/provider/aws/transformer/transformer_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package transformer | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/aws/aws-lambda-go/events" | ||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/elastic/beats/libbeat/common" | ||
) | ||
|
||
func TestKinesis(t *testing.T) { | ||
request := events.KinesisEvent{ | ||
Records: []events.KinesisEventRecord{ | ||
events.KinesisEventRecord{ | ||
AwsRegion: "us-east-1", | ||
EventID: "1234", | ||
EventName: "connect", | ||
EventSource: "web", | ||
EventVersion: "1.0", | ||
EventSourceArn: "arn:aws:iam::00000000:role/functionbeat", | ||
Kinesis: events.KinesisRecord{ | ||
Data: []byte("hello world"), | ||
PartitionKey: "abc123", | ||
SequenceNumber: "12345", | ||
KinesisSchemaVersion: "1.0", | ||
EncryptionType: "test", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
events := KinesisEvent(request) | ||
assert.Equal(t, 1, len(events)) | ||
|
||
fields := common.MapStr{ | ||
"event_id": "1234", | ||
"event_name": "connect", | ||
"event_source": "web", | ||
"event_source_arn": "arn:aws:iam::00000000:role/functionbeat", | ||
"event_version": "1.0", | ||
"aws_region": "us-east-1", | ||
"message": "hello world", | ||
"kinesis_partition_key": "abc123", | ||
"kinesis_schema_version": "1.0", | ||
"kinesis_sequence_number": "12345", | ||
"kinesis_encryption_type": "test", | ||
} | ||
|
||
assert.Equal(t, fields, events[0].Fields) | ||
} |