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
Adds a new optional parameter `s3_base_prefix` to the `awss3exporter`
which is used as the root path for all files uploaded.
This new parameter is helpful when using the
`resource_attrs_to_s3/s3_prefix` override ability but you still want a
root path to be used for all file uploads.
<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes#42661
<!--Describe what testing was performed and which tests were added.-->
#### Testing
Added unit tests and ran the otel collector locally using a config file
that specifies an `awss3` exporter with the new `s3_base_prefix`
parameter
<!--Describe the documentation added.-->
#### Documentation
Updated the readme and added new configuration examples
<!--Please delete paragraphs that you did not use before submitting.-->
|`s3_prefix`| prefix for the S3 key (root directory inside bucket). ||
27
+
|`s3_base_prefix`| root prefix for the S3 key applied to all files. ||
28
+
|`s3_prefix`| prefix for the S3 key that can be overridden dynamically by `resource_attrs_to_s3` parameter. ||
28
29
|`s3_partition_format`| filepath formatting for the partition; See [strftime](https://www.man7.org/linux/man-pages/man3/strftime.3.html) for format specification. | "year=%Y/month=%m/day=%d/hour=%H/minute=%M" |
29
30
|`s3_partition_timezone`| timezone used to format partition | Local |
30
31
|`role_arn`| the Role ARN to be assumed ||
@@ -145,6 +146,27 @@ metric/YYYY/MM/DD/HH/mm
145
146
Optionally along with `s3_partition_format` you can provide `s3_partition_timezone` as name from IANA Time Zone
146
147
database to change default local timezone to custom, for example `UTC` or `Europe/London`.
147
148
149
+
## Base Path Configuration
150
+
151
+
The `s3_base_prefix` option allows you to specify a root path inside the bucket that is not overridden by `resource_attrs_to_s3`. If provided, `s3_prefix` will be appended to this base path.
152
+
153
+
```yaml
154
+
exporters:
155
+
awss3:
156
+
s3uploader:
157
+
region: 'eu-central-1'
158
+
s3_bucket: 'databucket'
159
+
s3_base_prefix: 'environment/prod'
160
+
s3_prefix: 'metric'
161
+
s3_partition_format: '%Y/%m/%d/%H/%M'
162
+
```
163
+
164
+
In this case, logs and traces would be stored in the following path format.
165
+
166
+
```console
167
+
environment/prod/metric/YYYY/MM/DD/HH/mm
168
+
```
169
+
148
170
## Data routing based on resource attributes
149
171
When `resource_attrs_to_s3/s3_bucket` or `resource_attrs_to_s3/s3_prefix` is configured, the S3 bucket and/or prefix are dynamically derived from specified resource attributes in your data.
150
172
If the attribute values are unavailable, the bucket and prefix will fall back to the values defined in `s3uploader/s3_bucket` and `s3uploader/s3_prefix` respectively.
When using both `s3_base_prefix` and `resource_attrs_to_s3/s3_prefix`, the `s3_base_prefix` is always used while `s3_prefix` can be dynamically overridden by resource attributes.
# When resource attribute com.awss3.prefix = "service-b/logs"
223
+
environment/prod/service-b/logs/YYYY/MM/DD/HH/mm
224
+
225
+
# When resource attribute is unavailable (fallback)
226
+
environment/prod/default-metric/YYYY/MM/DD/HH/mm
227
+
```
228
+
229
+
This allows you to maintain consistent organizational structure (via base path) while dynamically routing different data types or services to specific subdirectories.
230
+
173
231
## Retry
174
232
175
233
Standard is the default retryer implementation used by service clients. See the [retry](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws/retry) package documentation for details on what errors are considered as retryable by the standard retryer implementation.
Copy file name to clipboardExpand all lines: exporter/awss3exporter/config.go
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,9 @@ type S3UploaderConfig struct {
25
25
Regionstring`mapstructure:"region"`
26
26
// S3Bucket is the bucket name to be uploaded to.
27
27
S3Bucketstring`mapstructure:"s3_bucket"`
28
-
// S3Prefix is the key (directory) prefix to written to inside the bucket
28
+
// S3BasePrefix is the root key (directory) prefix used to write the file.
29
+
S3BasePrefixstring`mapstructure:"s3_base_prefix"`
30
+
// S3Prefix is the key (directory) prefix to write to inside the bucket. Appended to S3BasePrefix if provided.
29
31
S3Prefixstring`mapstructure:"s3_prefix"`
30
32
// S3PartitionFormat is used to provide the rollup on how data is written. Uses [strftime](https://www.man7.org/linux/man-pages/man3/strftime.3.html) formatting.
0 commit comments