Skip to content

Commit 9b0a1f4

Browse files
davinkevinRoryCrispin
authored andcommitted
feat(awsS3Exporter): add support for s3_force_path_style and disable_ssl parameters (open-telemetry#29331)
**Description:** In order to support alternative object-storage, these parameters (`s3_force_path_style` and `disable_ssl`) are useful and help to leverage those object storage systems, not compatible with domain style path, or just hosted without ssl (like a minio pod deployed in a k8s namespace). **Testing:**: I've tested it in this project: https://gitlab.com/davinkevin.fr/experimentations/opentelemetry/spring-boot-otel-to-minio It was deployed in a k3d cluster and used to store metrics generated gathered by the prometheus receiver. **Documentation:**, minimal, just description of the two new parameters, usually well known by administrators or operators in charge to connect systems to their S3-Compatible storages.
1 parent 57bbf48 commit 9b0a1f4

File tree

6 files changed

+107
-20
lines changed

6 files changed

+107
-20
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: awss3exporter
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "add support for `s3_force_path_style` and `disable_ssl` parameters"
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [ 29331 ]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: |
19+
In order to support alternative object-storage, these parameters are useful and help to leverage those systems not
20+
compatible with domain style path, or just hosted without ssl (like just deployed in a k8s namespace).
21+
22+
# If your change doesn't affect end users or the exported elements of any package,
23+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
24+
# Optional: The change log or logs in which this entry should be included.
25+
# e.g. '[user]' or '[user, api]'
26+
# Include 'user' if the change is relevant to end users.
27+
# Include 'api' if there is a change to a library API.
28+
# Default: '[user]'
29+
change_logs: [ user ]

exporter/awss3exporter/README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,20 @@ This exporter targets to support proto/json format.
1919

2020
## Exporter Configuration
2121

22-
The following exporter configuration parameters are supported.
23-
24-
| Name | Description | Default |
25-
|:---------------|:-----------------------------------------------------------------------------------------------------|-------------|
26-
| `region` | AWS region. | "us-east-1" |
27-
| `s3_bucket` | S3 bucket | |
28-
| `s3_prefix` | prefix for the S3 key (root directory inside bucket). | |
29-
| `s3_partition` | time granularity of S3 key: hour or minute | "minute" |
30-
| `role_arn` | the Role ARN to be assumed | |
31-
| `file_prefix` | file prefix defined by user | |
32-
| `marshaler` | marshaler used to produce output data | `otlp_json` |
33-
| `endpoint` | overrides the endpoint used by the exporter instead of constructing it from `region` and `s3_bucket` | |
22+
The following exporter configuration parameters are supported.
23+
24+
| Name | Description | Default |
25+
|:----------------------|:---------------------------------------------------------------------------------------------------------------------------------------------|-------------|
26+
| `region` | AWS region. | "us-east-1" |
27+
| `s3_bucket` | S3 bucket | |
28+
| `s3_prefix` | prefix for the S3 key (root directory inside bucket). | |
29+
| `s3_partition` | time granularity of S3 key: hour or minute | "minute" |
30+
| `role_arn` | the Role ARN to be assumed | |
31+
| `file_prefix` | file prefix defined by user | |
32+
| `marshaler` | marshaler used to produce output data | `otlp_json` |
33+
| `endpoint` | overrides the endpoint used by the exporter instead of constructing it from `region` and `s3_bucket` | |
34+
| `s3_force_path_style` | [set this to `true` to force the request to use path-style addressing](http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html) | false |
35+
| `disable_ssl` | set this to `true` to disable SSL when sending requests | false |
3436

3537
### Marshaler
3638

exporter/awss3exporter/config.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ import (
1212
// S3UploaderConfig contains aws s3 uploader related config to controls things
1313
// like bucket, prefix, batching, connections, retries, etc.
1414
type S3UploaderConfig struct {
15-
Region string `mapstructure:"region"`
16-
S3Bucket string `mapstructure:"s3_bucket"`
17-
S3Prefix string `mapstructure:"s3_prefix"`
18-
S3Partition string `mapstructure:"s3_partition"`
19-
FilePrefix string `mapstructure:"file_prefix"`
20-
Endpoint string `mapstructure:"endpoint"`
21-
RoleArn string `mapstructure:"role_arn"`
15+
Region string `mapstructure:"region"`
16+
S3Bucket string `mapstructure:"s3_bucket"`
17+
S3Prefix string `mapstructure:"s3_prefix"`
18+
S3Partition string `mapstructure:"s3_partition"`
19+
FilePrefix string `mapstructure:"file_prefix"`
20+
Endpoint string `mapstructure:"endpoint"`
21+
RoleArn string `mapstructure:"role_arn"`
22+
S3ForcePathStyle bool `mapstructure:"s3_force_path_style"`
23+
DisableSSL bool `mapstructure:"disable_ssl"`
2224
}
2325

2426
type MarshalerType string

exporter/awss3exporter/config_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,36 @@ func TestConfig(t *testing.T) {
6767
)
6868
}
6969

70+
func TestConfigForS3CompatibleSystems(t *testing.T) {
71+
factories, err := otelcoltest.NopFactories()
72+
assert.Nil(t, err)
73+
74+
factory := NewFactory()
75+
factories.Exporters[factory.Type()] = factory
76+
cfg, err := otelcoltest.LoadConfigAndValidate(
77+
filepath.Join("testdata", "config-s3-compatible-systems.yaml"), factories)
78+
79+
require.NoError(t, err)
80+
require.NotNil(t, cfg)
81+
82+
e := cfg.Exporters[component.NewID("awss3")].(*Config)
83+
84+
assert.Equal(t, e,
85+
&Config{
86+
S3Uploader: S3UploaderConfig{
87+
Region: "us-east-1",
88+
S3Bucket: "foo",
89+
S3Prefix: "bar",
90+
S3Partition: "minute",
91+
Endpoint: "alternative-s3-system.example.com",
92+
S3ForcePathStyle: true,
93+
DisableSSL: true,
94+
},
95+
MarshalerName: "otlp_json",
96+
},
97+
)
98+
}
99+
70100
func TestConfig_Validate(t *testing.T) {
71101
tests := []struct {
72102
name string

exporter/awss3exporter/s3_writer.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ func getS3Key(time time.Time, keyPrefix string, partition string, filePrefix str
4949

5050
func getSessionConfig(config *Config) *aws.Config {
5151
sessionConfig := &aws.Config{
52-
Region: aws.String(config.S3Uploader.Region),
52+
Region: aws.String(config.S3Uploader.Region),
53+
S3ForcePathStyle: &config.S3Uploader.S3ForcePathStyle,
54+
DisableSSL: &config.S3Uploader.DisableSSL,
5355
}
5456

5557
endpoint := config.S3Uploader.Endpoint
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
receivers:
2+
nop:
3+
4+
exporters:
5+
awss3:
6+
s3uploader:
7+
s3_bucket: 'foo'
8+
s3_prefix: 'bar'
9+
s3_partition: 'minute'
10+
endpoint: "alternative-s3-system.example.com"
11+
s3_force_path_style: true
12+
disable_ssl: true
13+
14+
processors:
15+
nop:
16+
17+
service:
18+
pipelines:
19+
traces:
20+
receivers: [nop]
21+
processors: [nop]
22+
exporters: [awss3]

0 commit comments

Comments
 (0)