From 19d1ebb433a57da931f567a1ad2f8339b1173f48 Mon Sep 17 00:00:00 2001 From: Iacob Nicolaev Date: Tue, 24 Dec 2024 18:34:09 +0200 Subject: [PATCH] feat(http): add support for compress and reuse_connection options, and headers_from_placeholders in HTTPOutputConfig --- .../logging.banzaicloud.io_clusteroutputs.yaml | 16 ++++++++++++++++ .../logging.banzaicloud.io_outputs.yaml | 16 ++++++++++++++++ .../logging.banzaicloud.io_clusteroutputs.yaml | 16 ++++++++++++++++ .../crds/logging.banzaicloud.io_outputs.yaml | 16 ++++++++++++++++ .../logging.banzaicloud.io_clusteroutputs.yaml | 16 ++++++++++++++++ .../bases/logging.banzaicloud.io_outputs.yaml | 16 ++++++++++++++++ docs/configuration/plugins/outputs/http.md | 17 +++++++++++++++++ pkg/sdk/logging/model/output/http.go | 6 ++++++ .../model/output/zz_generated.deepcopy.go | 7 +++++++ 9 files changed, 126 insertions(+) diff --git a/charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_clusteroutputs.yaml b/charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_clusteroutputs.yaml index bc8cae1a2..ca73eda75 100644 --- a/charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_clusteroutputs.yaml +++ b/charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_clusteroutputs.yaml @@ -2855,6 +2855,8 @@ spec: type: type: string type: object + compress: + type: string content_type: type: string endpoint: @@ -2882,6 +2884,10 @@ spec: additionalProperties: type: string type: object + headers_from_placeholders: + additionalProperties: + type: string + type: object http_method: type: string json_array: @@ -2896,6 +2902,8 @@ spec: items: type: integer type: array + reuse_connection: + type: boolean slow_flush_log_threshold: type: string ssl_timeout: @@ -10294,6 +10302,8 @@ spec: type: type: string type: object + compress: + type: string content_type: type: string endpoint: @@ -10321,6 +10331,10 @@ spec: additionalProperties: type: string type: object + headers_from_placeholders: + additionalProperties: + type: string + type: object http_method: type: string json_array: @@ -10335,6 +10349,8 @@ spec: items: type: integer type: array + reuse_connection: + type: boolean slow_flush_log_threshold: type: string ssl_timeout: diff --git a/charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_outputs.yaml b/charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_outputs.yaml index 3a90b6364..1e71d8fed 100644 --- a/charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_outputs.yaml +++ b/charts/logging-operator/charts/logging-operator-crds/templates/logging.banzaicloud.io_outputs.yaml @@ -2851,6 +2851,8 @@ spec: type: type: string type: object + compress: + type: string content_type: type: string endpoint: @@ -2878,6 +2880,10 @@ spec: additionalProperties: type: string type: object + headers_from_placeholders: + additionalProperties: + type: string + type: object http_method: type: string json_array: @@ -2892,6 +2898,8 @@ spec: items: type: integer type: array + reuse_connection: + type: boolean slow_flush_log_threshold: type: string ssl_timeout: @@ -9564,6 +9572,8 @@ spec: type: type: string type: object + compress: + type: string content_type: type: string endpoint: @@ -9591,6 +9601,10 @@ spec: additionalProperties: type: string type: object + headers_from_placeholders: + additionalProperties: + type: string + type: object http_method: type: string json_array: @@ -9605,6 +9619,8 @@ spec: items: type: integer type: array + reuse_connection: + type: boolean slow_flush_log_threshold: type: string ssl_timeout: diff --git a/charts/logging-operator/crds/logging.banzaicloud.io_clusteroutputs.yaml b/charts/logging-operator/crds/logging.banzaicloud.io_clusteroutputs.yaml index 53b84f535..144941571 100644 --- a/charts/logging-operator/crds/logging.banzaicloud.io_clusteroutputs.yaml +++ b/charts/logging-operator/crds/logging.banzaicloud.io_clusteroutputs.yaml @@ -2852,6 +2852,8 @@ spec: type: type: string type: object + compress: + type: string content_type: type: string endpoint: @@ -2879,6 +2881,10 @@ spec: additionalProperties: type: string type: object + headers_from_placeholders: + additionalProperties: + type: string + type: object http_method: type: string json_array: @@ -2893,6 +2899,8 @@ spec: items: type: integer type: array + reuse_connection: + type: boolean slow_flush_log_threshold: type: string ssl_timeout: @@ -10291,6 +10299,8 @@ spec: type: type: string type: object + compress: + type: string content_type: type: string endpoint: @@ -10318,6 +10328,10 @@ spec: additionalProperties: type: string type: object + headers_from_placeholders: + additionalProperties: + type: string + type: object http_method: type: string json_array: @@ -10332,6 +10346,8 @@ spec: items: type: integer type: array + reuse_connection: + type: boolean slow_flush_log_threshold: type: string ssl_timeout: diff --git a/charts/logging-operator/crds/logging.banzaicloud.io_outputs.yaml b/charts/logging-operator/crds/logging.banzaicloud.io_outputs.yaml index cb9b1b4cc..783f9d487 100644 --- a/charts/logging-operator/crds/logging.banzaicloud.io_outputs.yaml +++ b/charts/logging-operator/crds/logging.banzaicloud.io_outputs.yaml @@ -2848,6 +2848,8 @@ spec: type: type: string type: object + compress: + type: string content_type: type: string endpoint: @@ -2875,6 +2877,10 @@ spec: additionalProperties: type: string type: object + headers_from_placeholders: + additionalProperties: + type: string + type: object http_method: type: string json_array: @@ -2889,6 +2895,8 @@ spec: items: type: integer type: array + reuse_connection: + type: boolean slow_flush_log_threshold: type: string ssl_timeout: @@ -9561,6 +9569,8 @@ spec: type: type: string type: object + compress: + type: string content_type: type: string endpoint: @@ -9588,6 +9598,10 @@ spec: additionalProperties: type: string type: object + headers_from_placeholders: + additionalProperties: + type: string + type: object http_method: type: string json_array: @@ -9602,6 +9616,8 @@ spec: items: type: integer type: array + reuse_connection: + type: boolean slow_flush_log_threshold: type: string ssl_timeout: diff --git a/config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml b/config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml index 53b84f535..144941571 100644 --- a/config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml +++ b/config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml @@ -2852,6 +2852,8 @@ spec: type: type: string type: object + compress: + type: string content_type: type: string endpoint: @@ -2879,6 +2881,10 @@ spec: additionalProperties: type: string type: object + headers_from_placeholders: + additionalProperties: + type: string + type: object http_method: type: string json_array: @@ -2893,6 +2899,8 @@ spec: items: type: integer type: array + reuse_connection: + type: boolean slow_flush_log_threshold: type: string ssl_timeout: @@ -10291,6 +10299,8 @@ spec: type: type: string type: object + compress: + type: string content_type: type: string endpoint: @@ -10318,6 +10328,10 @@ spec: additionalProperties: type: string type: object + headers_from_placeholders: + additionalProperties: + type: string + type: object http_method: type: string json_array: @@ -10332,6 +10346,8 @@ spec: items: type: integer type: array + reuse_connection: + type: boolean slow_flush_log_threshold: type: string ssl_timeout: diff --git a/config/crd/bases/logging.banzaicloud.io_outputs.yaml b/config/crd/bases/logging.banzaicloud.io_outputs.yaml index cb9b1b4cc..783f9d487 100644 --- a/config/crd/bases/logging.banzaicloud.io_outputs.yaml +++ b/config/crd/bases/logging.banzaicloud.io_outputs.yaml @@ -2848,6 +2848,8 @@ spec: type: type: string type: object + compress: + type: string content_type: type: string endpoint: @@ -2875,6 +2877,10 @@ spec: additionalProperties: type: string type: object + headers_from_placeholders: + additionalProperties: + type: string + type: object http_method: type: string json_array: @@ -2889,6 +2895,8 @@ spec: items: type: integer type: array + reuse_connection: + type: boolean slow_flush_log_threshold: type: string ssl_timeout: @@ -9561,6 +9569,8 @@ spec: type: type: string type: object + compress: + type: string content_type: type: string endpoint: @@ -9588,6 +9598,10 @@ spec: additionalProperties: type: string type: object + headers_from_placeholders: + additionalProperties: + type: string + type: object http_method: type: string json_array: @@ -9602,6 +9616,8 @@ spec: items: type: integer type: array + reuse_connection: + type: boolean slow_flush_log_threshold: type: string ssl_timeout: diff --git a/docs/configuration/plugins/outputs/http.md b/docs/configuration/plugins/outputs/http.md index 0a63ebb9f..06a5cdb5f 100644 --- a/docs/configuration/plugins/outputs/http.md +++ b/docs/configuration/plugins/outputs/http.md @@ -34,6 +34,12 @@ spec: [Buffer](../buffer/) +### compress (string, optional) {#output config-compress} + +The option to compress HTTP request body. [text,gzip] + +Default: text + ### content_type (string, optional) {#output config-content_type} Content-Profile for HTTP request. @@ -66,6 +72,11 @@ Default: post Additional headers for HTTP request. +### headers_from_placeholders (map[string]string, optional) {#output config-headers_from_placeholders} + +Additional headers from placeholders for HTTP request. + + ### json_array (bool, optional) {#output config-json_array} Using array format of JSON. This parameter is used and valid only for json format. When json_array as true, Content-Profile should be application/json and be able to use JSON data for the HTTP request body. @@ -93,6 +104,12 @@ List of retryable response codes. If the response code is included in this list, Default: [503] +### reuse_connection (bool, optional) {#output config-reuse_connection} + +Try to reuse connection. This will improve performance. + +Default: false + ### ssl_timeout (int, optional) {#output config-ssl_timeout} TLS timeout in seconds. diff --git a/pkg/sdk/logging/model/output/http.go b/pkg/sdk/logging/model/output/http.go index 1d4c599ac..3031d8fee 100644 --- a/pkg/sdk/logging/model/output/http.go +++ b/pkg/sdk/logging/model/output/http.go @@ -61,16 +61,22 @@ type HTTPOutputConfig struct { ContentType string `json:"content_type,omitempty"` // Using array format of JSON. This parameter is used and valid only for json format. When json_array as true, Content-Profile should be application/json and be able to use JSON data for the HTTP request body. (default: false) JsonArray bool `json:"json_array,omitempty"` + // The option to compress HTTP request body. [text,gzip] (default: text) + Compress string `json:"compress,omitempty"` // +docLink:"Format,../format/" Format *Format `json:"format,omitempty"` // Additional headers for HTTP request. Headers map[string]string `json:"headers,omitempty"` + // Additional headers from placeholders for HTTP request. + HeadersFromPlaceholders map[string]string `json:"headers_from_placeholders,omitempty"` // Connection open timeout in seconds. OpenTimeout int `json:"open_timeout,omitempty"` // Read timeout in seconds. ReadTimeout int `json:"read_timeout,omitempty"` // TLS timeout in seconds. SSLTimeout int `json:"ssl_timeout,omitempty"` + // Try to reuse connection. This will improve performance. (default: false) + ReuseConnection bool `json:"reuse_connection,omitempty"` // The default version of TLS transport. [TLSv1_1, TLSv1_2] (default: TLSv1_2) TlsVersion string `json:"tls_version,omitempty"` // The cipher configuration of TLS transport. (default: ALL:!aNULL:!eNULL:!SSLv2) diff --git a/pkg/sdk/logging/model/output/zz_generated.deepcopy.go b/pkg/sdk/logging/model/output/zz_generated.deepcopy.go index b5bac4221..6789fdf07 100644 --- a/pkg/sdk/logging/model/output/zz_generated.deepcopy.go +++ b/pkg/sdk/logging/model/output/zz_generated.deepcopy.go @@ -637,6 +637,13 @@ func (in *HTTPOutputConfig) DeepCopyInto(out *HTTPOutputConfig) { (*out)[key] = val } } + if in.HeadersFromPlaceholders != nil { + in, out := &in.HeadersFromPlaceholders, &out.HeadersFromPlaceholders + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.TlsCACertPath != nil { in, out := &in.TlsCACertPath, &out.TlsCACertPath *out = new(secret.Secret)