You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
This PR adds support for routing S3 objects to different encoding
extensions based on their key prefix within a
single Lambda deployment.
This is useful when a Lambda receives events from S3 buckets that
store multiple log types (e.g. VPC Flow Logs and CloudTrail in the same
bucket, or across
multiple buckets with different log types).
We introduce a new `encodings` field in the S3 receiver config that can
be used like this:
```yaml
extensions:
awslogs_encoding/vpcflow:
format: vpcflow
vpcflow:
file_format: plain-text
awslogs_encoding/cloudtrail:
format: cloudtrail
receivers:
awslambda:
s3:
encodings:
- name: vpcflow
encoding: awslogs_encoding/vpcflow # decode VPC Flow Log fields into structured records
- name: cloudtrail
encoding: awslogs_encoding/cloudtrail # decode CloudTrail JSON events into structured records
path_pattern: "myorg/*/CloudTrail" # optional: override default (AWSLogs/*/CloudTrail); omit to use the default
- name: catchall
path_pattern: "*" # forward anything else as raw bytes
```
The existing `encoding` field is unchanged. `encoding` and `encodings`
are mutually
exclusive.
<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Part of
#46458
<!--Describe what testing was performed and which tests were added.-->
#### Testing
Unit Testing.
Pending E2E testing.
<!--Describe the documentation added.-->
#### Documentation
Readme has been updated.
<!--Please delete paragraphs that you did not use before submitting.-->
Copy file name to clipboardExpand all lines: receiver/awslambdareceiver/README.md
+74Lines changed: 74 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -289,6 +289,80 @@ service:
289
289
290
290
Similar to the first example, this configuration is for collecting ELB access logs stored in S3.
291
291
292
+
### Multi-Format S3 Configuration (encodings)
293
+
294
+
The `encodings` field enables routing different S3 object key patterns to different decoders within
295
+
a single Lambda deployment. This is useful when a Lambda function receives events from:
296
+
297
+
- **A single S3 bucket that stores multiple log types** — for example, VPC Flow Logs and CloudTrail
298
+
logs written to the same bucket under different key prefixes.
299
+
- **Multiple S3 buckets with different log types** — for example, one bucket for VPC Flow Logs and
300
+
another for WAF logs, both configured to trigger the same Lambda function.
301
+
302
+
`encoding`(single, top-level) and `encodings` (list) are mutually exclusive — use one or the other.
303
+
304
+
Each entry in `encodings` supports three fields:
305
+
306
+
| Field | Required | Description |
307
+
|----------------|----------|-------------|
308
+
| `name` | yes | Unique identifier for this entry. For known names (`vpcflow`, `cloudtrail`, etc.) the default `path_pattern` is applied automatically. |
309
+
| `encoding` | no | Extension ID of the decoder (e.g. `awslogs_encoding/vpcflow`). Omit to pass content through as raw bytes using the built-in default decoder. |
310
+
| `path_pattern` | no* | Prefix pattern matched against the S3 object key. `*` matches one path segment. Omit to use the built-in default for known names. Use `"*"` as a catch-all. |
311
+
312
+
\* May be omitted only for built-in known names. For any other name, `path_pattern` must be set explicitly (use `"*"` for a catch-all).
313
+
314
+
Each entry in `encodings` is evaluated in order of pattern specificity (more-specific patterns are
315
+
matched first; `"*"` catch-all is matched last). Users may list entries in any order.
316
+
317
+
#### Combining encodings with extensions
318
+
319
+
The `encoding` field references a collector extension by its component ID. Each referenced
320
+
extension must be declared in the `extensions:` block and listed under `service.extensions`.
321
+
322
+
The following example decodes VPC Flow Logs and CloudTrail events into structured log records,
323
+
and forwards anything else as raw bytes via the catch-all entry:
324
+
325
+
```yaml
326
+
extensions:
327
+
awslogs_encoding/vpcflow:
328
+
format: vpcflow
329
+
vpcflow:
330
+
file_format: plain-text
331
+
awslogs_encoding/cloudtrail:
332
+
format: cloudtrail
333
+
334
+
receivers:
335
+
awslambda:
336
+
s3:
337
+
encodings:
338
+
- name: vpcflow
339
+
encoding: awslogs_encoding/vpcflow # decode VPC Flow Log fields into structured records
340
+
- name: cloudtrail
341
+
encoding: awslogs_encoding/cloudtrail # decode CloudTrail JSON events into structured records
342
+
path_pattern: "myorg/*/CloudTrail" # optional: override default (AWSLogs/*/CloudTrail); omit to use the default
343
+
- name: catchall
344
+
path_pattern: "*" # forward anything else as raw bytes
345
+
346
+
```
347
+
348
+
#### Built-in default path patterns
349
+
350
+
The following well-known names have built-in default path patterns. When `path_pattern` is omitted
351
+
for these names, the receiver uses the corresponding default.
description: S3Config defines configuration options for the S3 Lambda trigger. It supersedes the sharedConfig for the s3 key. sharedConfig is embedded with mapstructure:",squash" so the "encoding" key remains at the top level of the s3 block in YAML — fully backwards-compatible.
4
+
type: object
5
+
properties:
6
+
encoding:
7
+
description: Encoding defines the encoding to decode incoming Lambda invocation data.
8
+
type: string
9
+
encodings:
10
+
description: Encodings defines multiple encoding entries for S3 path-based routing (multi-format mode). Each entry maps a path_pattern prefix to an encoding extension. Mutually exclusive with sharedConfig.Encoding. Only supported for logs signal type. Metrics receivers reject configs that set this field.
11
+
type: array
12
+
items:
13
+
$ref: s_3_encoding
14
+
s_3_encoding:
15
+
description: S3Encoding defines one entry in the S3 multi-encoding routing table.
16
+
type: object
17
+
properties:
18
+
encoding:
19
+
description: Encoding is the extension ID for decoding (e.g. "awslogs_encoding/vpcflow"). If empty, content is passed through as-is using the built-in raw decoder.
20
+
type: string
21
+
name:
22
+
description: Name identifies the encoding. For known names (vpcflow, cloudtrail, elbaccess, waf, networkfirewall) the default path_pattern is applied automatically.
23
+
type: string
24
+
path_pattern:
25
+
description: 'PathPattern is matched as a prefix against the S3 object key. "*" matches exactly one path segment. Example: "AWSLogs/*/vpcflowlogs" If empty, the default pattern for a known Name is used.'
26
+
type: string
27
+
description: Config is the top-level configuration for the awslambda receiver.
1
28
type: object
2
29
properties:
3
30
cloudwatch:
4
-
description: CloudWatch defines configuration options for CloudWatch Lambda trigger.
31
+
description: CloudWatch defines configuration for the CloudWatch Logs Lambda trigger.
5
32
type: object
6
33
properties:
7
34
encoding:
8
-
description: Encoding defines the encoding to decode incoming Lambda invocation data. This extension is expected to further process content of the events that are extracted from Lambda trigger. If receiving data is in different formats(ex:- a mix of VPC flow logs, CloudTrail logs), receiver is recommended to have separate Lambda functions with specific extension configurations.
35
+
description: Encoding defines the encoding to decode incoming Lambda invocation data.
9
36
type: string
10
37
failure_bucket_arn:
11
-
description: FailureBucketARN is the ARN of receiver deployment Lambda's error destination.
38
+
description: FailureBucketARN is the ARN of the S3 bucket used to store failed Lambda event records.
12
39
type: string
13
40
s3:
14
-
description: S3 defines configuration options for S3 Lambda trigger.
15
-
type: object
16
-
properties:
17
-
encoding:
18
-
description: Encoding defines the encoding to decode incoming Lambda invocation data. This extension is expected to further process content of the events that are extracted from Lambda trigger. If receiving data is in different formats(ex:- a mix of VPC flow logs, CloudTrail logs), receiver is recommended to have separate Lambda functions with specific extension configurations.
19
-
type: string
41
+
description: S3 defines configuration for the S3 Lambda trigger.
0 commit comments