From 016db28505585444e09789d1ef91e31b0b15f8ad Mon Sep 17 00:00:00 2001 From: Timon Engelke Date: Fri, 25 Apr 2025 09:05:45 +0200 Subject: [PATCH 1/2] feat(opensearch): add option to enable gzip compression Signed-off-by: Timon Engelke --- README.md | 2 ++ pkg/sinks/opensearch.go | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f74bd5f4..ac85d19f 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,8 @@ receivers: insecureSkipVerify: true|false # optional, if set to true, the tls cert won't be verified serverName: # optional, the domain, the certificate was issued for, in case it doesn't match the hostname used for the connection caFile: # optional, path to the CA file of the trusted authority the cert was signed with + # If set to true, gzip compression is used for requests to OpenSearch. Defaults to false. + compressRequestBody: true|false ``` ### Slack diff --git a/pkg/sinks/opensearch.go b/pkg/sinks/opensearch.go index 6f58507d..09795d53 100644 --- a/pkg/sinks/opensearch.go +++ b/pkg/sinks/opensearch.go @@ -25,12 +25,13 @@ type OpenSearchConfig struct { // Indexing preferences UseEventID bool `yaml:"useEventID"` // DeDot all labels and annotations in the event. For both the event and the involvedObject - DeDot bool `yaml:"deDot"` - Index string `yaml:"index"` - IndexFormat string `yaml:"indexFormat"` - Type string `yaml:"type"` - TLS TLS `yaml:"tls"` - Layout map[string]interface{} `yaml:"layout"` + DeDot bool `yaml:"deDot"` + Index string `yaml:"index"` + IndexFormat string `yaml:"indexFormat"` + Type string `yaml:"type"` + TLS TLS `yaml:"tls"` + Layout map[string]interface{} `yaml:"layout"` + CompressRequestBody bool `yaml:"compressRequestBody"` } func NewOpenSearch(cfg *OpenSearchConfig) (*OpenSearch, error) { @@ -47,6 +48,7 @@ func NewOpenSearch(cfg *OpenSearchConfig) (*OpenSearch, error) { Transport: &http.Transport{ TLSClientConfig: tlsClientConfig, }, + CompressRequestBody: cfg.CompressRequestBody, }) if err != nil { return nil, err From 0a1f6724a0767ba875b8918dddb8651ea7d842dc Mon Sep 17 00:00:00 2001 From: Timon Engelke Date: Fri, 25 Apr 2025 10:00:23 +0200 Subject: [PATCH 2/2] feat(elasticsearch): add option to enable gzip compression Signed-off-by: Timon Engelke --- README.md | 2 ++ pkg/sinks/elasticsearch.go | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ac85d19f..23574ff8 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,8 @@ receivers: insecureSkipVerify: true|false # optional, if set to true, the tls cert won't be verified serverName: # optional, the domain, the certificate was issued for, in case it doesn't match the hostname used for the connection caFile: # optional, path to the CA file of the trusted authority the cert was signed with + # If set to true, gzip compression is used for requests to ElasticSearch. Defaults to false. + compressRequestBody: true|false ``` ### OpenSearch diff --git a/pkg/sinks/elasticsearch.go b/pkg/sinks/elasticsearch.go index 780566f7..0b04affa 100644 --- a/pkg/sinks/elasticsearch.go +++ b/pkg/sinks/elasticsearch.go @@ -28,12 +28,13 @@ type ElasticsearchConfig struct { // Indexing preferences UseEventID bool `yaml:"useEventID"` // DeDot all labels and annotations in the event. For both the event and the involvedObject - DeDot bool `yaml:"deDot"` - Index string `yaml:"index"` - IndexFormat string `yaml:"indexFormat"` - Type string `yaml:"type"` - TLS TLS `yaml:"tls"` - Layout map[string]interface{} `yaml:"layout"` + DeDot bool `yaml:"deDot"` + Index string `yaml:"index"` + IndexFormat string `yaml:"indexFormat"` + Type string `yaml:"type"` + TLS TLS `yaml:"tls"` + Layout map[string]interface{} `yaml:"layout"` + CompressRequestBody bool `yaml:"compressRequestBody"` } func NewElasticsearch(cfg *ElasticsearchConfig) (*Elasticsearch, error) { @@ -60,6 +61,7 @@ func NewElasticsearch(cfg *ElasticsearchConfig) (*Elasticsearch, error) { Transport: &http.Transport{ TLSClientConfig: tlsClientConfig, }, + CompressRequestBody: cfg.CompressRequestBody, }) if err != nil { return nil, err