-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[extension/awslogsencodingextension] Add source_region field (27th field) to S3 server access log parser and skip unknown future fields gracefully.
#47149
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
Merged
edmocosta
merged 6 commits into
open-telemetry:main
from
raulmartinezr:fix/s3-access-log-source-region-field
Apr 2, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5730900
[extension/awslogsencodingextension] fix s3access parser: add source_…
raulmartinezr 3a8c648
Merge branch 'main' into fix/s3-access-log-source-region-field
raulmartinezr 9dcb4da
Merge branch 'main' into fix/s3-access-log-source-region-field
raulmartinezr 8004e45
Merge branch 'main' into fix/s3-access-log-source-region-field
raulmartinezr 90b9c69
Update .chloggen/fix-s3-access-log-source-region-field.yaml
axw fc81093
Merge branch 'main' into fix/s3-access-log-source-region-field
axw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,17 @@ | ||
| change_type: bug_fix | ||
|
|
||
| component: extension/aws_logs_encoding | ||
|
|
||
| note: Add `source_region` field (27th field) to S3 server access log parser and skip unknown future fields gracefully. | ||
|
|
||
| issues: [47149] | ||
|
|
||
| subtext: | | ||
| AWS added a `source_region` field to the S3 server access log format. The parser | ||
| previously returned an error ("values in log line exceed the number of available fields") | ||
| when it encountered log lines with more fields than defined. This fix: | ||
| - Adds `source_region` as field index 26 mapped to `aws.s3.source_region`. | ||
| - Makes the parser skip any fields beyond the known schema instead of failing, | ||
| providing forward compatibility with future AWS S3 access log additions. | ||
|
|
||
| change_logs: [user] |
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
.../awslogsencodingextension/internal/unmarshaler/s3-access-log/testdata/too_many_values.log
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| 79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be amzn-s3-demo-bucket1 [06/Feb/2019:00:00:38 +0000] 192.0.2.3 79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be 3E57427F3EXAMPLE REST.GET.VERSIONING - "GET /amzn-s3-demo-bucket1?versioning HTTP/1.1" 200 - 113 - 7 - "-" "S3Console/0.4" - s9lzHYrFp76ZVxRcpX9+5cjAnEH2ROuNkd2BHfIa6UkFVdtjf5mKR3/eTPFvsiP/XV/VLi31234= SigV4 ECDHE-RSA-AES128-GCM-SHA256 AuthHeader amzn-s3-demo-bucket1.s3.us-west-1.amazonaws.com TLSV1.2 arn:aws:s3:us-west-1:123456789012:accesspoint/example-AP Yes TooMany | ||
| 79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be amzn-s3-demo-bucket1 [06/Feb/2019:00:00:38 +0000] 192.0.2.3 79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be 3E57427F3EXAMPLE REST.GET.VERSIONING - "GET /amzn-s3-demo-bucket1?versioning HTTP/1.1" 200 - 113 - 7 - "-" "S3Console/0.4" - s9lzHYrFp76ZVxRcpX9+5cjAnEH2ROuNkd2BHfIa6UkFVdtjf5mKR3/eTPFvsiP/XV/VLi31234= SigV4 ECDHE-RSA-AES128-GCM-SHA256 AuthHeader amzn-s3-demo-bucket1.s3.us-west-1.amazonaws.com TLSV1.2 arn:aws:s3:us-west-1:123456789012:accesspoint/example-AP Yes us-east-1 ExtraUnknownField |
89 changes: 89 additions & 0 deletions
89
...codingextension/internal/unmarshaler/s3-access-log/testdata/too_many_values_expected.yaml
This file contains hidden or 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,89 @@ | ||
| resourceLogs: | ||
| - resource: | ||
| attributes: | ||
| - key: cloud.provider | ||
| value: | ||
| stringValue: aws | ||
| - key: aws.s3.bucket | ||
| value: | ||
| stringValue: amzn-s3-demo-bucket1 | ||
| - key: aws.s3.owner | ||
| value: | ||
| stringValue: 79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be | ||
| scopeLogs: | ||
| - logRecords: | ||
| - attributes: | ||
| - key: source.address | ||
| value: | ||
| stringValue: 192.0.2.3 | ||
| - key: user.id | ||
| value: | ||
| stringValue: 79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be | ||
| - key: aws.request_id | ||
| value: | ||
| stringValue: 3E57427F3EXAMPLE | ||
| - key: rpc.method | ||
| value: | ||
| stringValue: REST.GET.VERSIONING | ||
| - key: http.request.method | ||
| value: | ||
| stringValue: GET | ||
| - key: url.path | ||
| value: | ||
| stringValue: /amzn-s3-demo-bucket1 | ||
| - key: url.query | ||
| value: | ||
| stringValue: versioning | ||
| - key: network.protocol.name | ||
| value: | ||
| stringValue: http | ||
| - key: network.protocol.version | ||
| value: | ||
| stringValue: "1.1" | ||
| - key: http.response.status_code | ||
| value: | ||
| intValue: "200" | ||
| - key: http.response.body.size | ||
| value: | ||
| intValue: "113" | ||
| - key: duration | ||
| value: | ||
| intValue: "7" | ||
| - key: user_agent.original | ||
| value: | ||
| stringValue: S3Console/0.4 | ||
| - key: aws.extended_request_id | ||
| value: | ||
| stringValue: s9lzHYrFp76ZVxRcpX9+5cjAnEH2ROuNkd2BHfIa6UkFVdtjf5mKR3/eTPFvsiP/XV/VLi31234= | ||
| - key: aws.signature.version | ||
| value: | ||
| stringValue: SigV4 | ||
| - key: tls.cipher | ||
| value: | ||
| stringValue: ECDHE-RSA-AES128-GCM-SHA256 | ||
| - key: aws.s3.auth_type | ||
| value: | ||
| stringValue: AuthHeader | ||
| - key: http.request.header.host | ||
| value: | ||
| stringValue: amzn-s3-demo-bucket1.s3.us-west-1.amazonaws.com | ||
| - key: tls.protocol.version | ||
| value: | ||
| stringValue: "1.2" | ||
| - key: aws.s3.access_point.arn | ||
| value: | ||
| stringValue: arn:aws:s3:us-west-1:123456789012:accesspoint/example-AP | ||
| - key: aws.s3.acl_required | ||
| value: | ||
| boolValue: true | ||
| - key: aws.s3.source_region | ||
| value: | ||
| stringValue: us-east-1 | ||
| body: {} | ||
| timeUnixNano: "1549411238000000000" | ||
| scope: | ||
| attributes: | ||
| - key: encoding.format | ||
| value: | ||
| stringValue: aws.s3access | ||
| name: github.com/open-telemetry/opentelemetry-collector-contrib/extension/encoding/awslogsencodingextension |
2 changes: 1 addition & 1 deletion
2
...logsencodingextension/internal/unmarshaler/s3-access-log/testdata/valid_s3_access_log.log
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| 79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be amzn-s3-demo-bucket1 [06/Feb/2019:00:00:38 +0000] 192.0.2.3 79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be 3E57427F3EXAMPLE REST.GET.VERSIONING - "GET /amzn-s3-demo-bucket1?versioning HTTP/1.1" 200 - 113 - 7 - "-" "S3Console/0.4" - s9lzHYrFp76ZVxRcpX9+5cjAnEH2ROuNkd2BHfIa6UkFVdtjf5mKR3/eTPFvsiP/XV/VLi31234= SigV4 ECDHE-RSA-AES128-GCM-SHA256 AuthHeader amzn-s3-demo-bucket1.s3.us-west-1.amazonaws.com TLSV1.2 arn:aws:s3:us-west-1:123456789012:accesspoint/example-AP Yes | ||
| 79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be amzn-s3-demo-bucket1 [06/Feb/2019:00:00:38 +0000] 192.0.2.3 79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2be 3E57427F3EXAMPLE REST.GET.VERSIONING - "GET /amzn-s3-demo-bucket1?versioning HTTP/1.1" 200 - 113 - 7 - "-" "S3Console/0.4" - s9lzHYrFp76ZVxRcpX9+5cjAnEH2ROuNkd2BHfIa6UkFVdtjf5mKR3/eTPFvsiP/XV/VLi31234= SigV4 ECDHE-RSA-AES128-GCM-SHA256 AuthHeader amzn-s3-demo-bucket1.s3.us-west-1.amazonaws.com TLSV1.2 arn:aws:s3:us-west-1:123456789012:accesspoint/example-AP Yes us-east-1 |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the standard
cloud.regionattribute be appropriate here? Not as a resource attribute (that would more appropriate for identifying the S3 bucket region), but as a log record attribute.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per AWS documentation, source_region is defined as "the AWS Region from which the request originated" — i.e. the caller's region, not the resource's region. Mapping this to cloud.region (whose OTel semantics describe where a resource lives) would invert the meaning. aws.s3.source_region keeps the intent unambiguous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What it says is:
"When associated with a resource, this attribute specifies the region where the resource operates. When calling services or APIs deployed on a cloud, this attribute identifies the region where the called destination is deployed."
So it's not just where the resource (in the OTel data model sense) lives, but may also refer to where the target of an operation lives. What's missing is describing where the source of an operation lives.
Anyway, I'm OK with starting with
aws.s3.source_region, but we may want to revisit this later on.