From e75e1e2374a7285e81397364342a864fb9c202b2 Mon Sep 17 00:00:00 2001 From: Bartosz Date: Wed, 28 Aug 2024 13:18:59 +0200 Subject: [PATCH 1/4] chart: add missing flag for gelf output plugin Signed-off-by: Bartosz --- .../crds/logging.banzaicloud.io_clusteroutputs.yaml | 4 ++++ .../logging-operator/crds/logging.banzaicloud.io_outputs.yaml | 4 ++++ config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml | 4 ++++ config/crd/bases/logging.banzaicloud.io_outputs.yaml | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/charts/logging-operator/crds/logging.banzaicloud.io_clusteroutputs.yaml b/charts/logging-operator/crds/logging.banzaicloud.io_clusteroutputs.yaml index 5408b69f3..ca0421420 100644 --- a/charts/logging-operator/crds/logging.banzaicloud.io_clusteroutputs.yaml +++ b/charts/logging-operator/crds/logging.banzaicloud.io_clusteroutputs.yaml @@ -2685,6 +2685,8 @@ spec: type: object host: type: string + max_bytes: + type: integer port: type: integer protocol: @@ -10084,6 +10086,8 @@ spec: type: object host: type: string + max_bytes: + type: integer port: type: integer protocol: diff --git a/charts/logging-operator/crds/logging.banzaicloud.io_outputs.yaml b/charts/logging-operator/crds/logging.banzaicloud.io_outputs.yaml index a8f59c208..e9e93c3ec 100644 --- a/charts/logging-operator/crds/logging.banzaicloud.io_outputs.yaml +++ b/charts/logging-operator/crds/logging.banzaicloud.io_outputs.yaml @@ -2681,6 +2681,8 @@ spec: type: object host: type: string + max_bytes: + type: integer port: type: integer protocol: @@ -9354,6 +9356,8 @@ spec: type: object host: type: string + max_bytes: + type: integer port: type: integer protocol: diff --git a/config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml b/config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml index 5408b69f3..ca0421420 100644 --- a/config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml +++ b/config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml @@ -2685,6 +2685,8 @@ spec: type: object host: type: string + max_bytes: + type: integer port: type: integer protocol: @@ -10084,6 +10086,8 @@ spec: type: object host: type: string + max_bytes: + type: integer port: type: integer protocol: diff --git a/config/crd/bases/logging.banzaicloud.io_outputs.yaml b/config/crd/bases/logging.banzaicloud.io_outputs.yaml index a8f59c208..e9e93c3ec 100644 --- a/config/crd/bases/logging.banzaicloud.io_outputs.yaml +++ b/config/crd/bases/logging.banzaicloud.io_outputs.yaml @@ -2681,6 +2681,8 @@ spec: type: object host: type: string + max_bytes: + type: integer port: type: integer protocol: @@ -9354,6 +9356,8 @@ spec: type: object host: type: string + max_bytes: + type: integer port: type: integer protocol: From d0aaa4bcc73cea4aeb54392ac461482fe0b6e36c Mon Sep 17 00:00:00 2001 From: Bartosz Date: Wed, 28 Aug 2024 13:20:31 +0200 Subject: [PATCH 2/4] docs: improved gelf docs Signed-off-by: Bartosz --- .../crds/v1beta1/output_types.md | 2 +- docs/configuration/plugins/_index.md | 2 +- docs/configuration/plugins/outputs/gelf.md | 56 ++++++---------- pkg/sdk/logging/api/v1alpha1/output_types.go | 2 +- .../api/v1alpha1/zz_generated.deepcopy.go | 6 +- pkg/sdk/logging/api/v1beta1/output_types.go | 2 +- .../api/v1beta1/zz_generated.deepcopy.go | 6 +- pkg/sdk/logging/model/output/gelf.go | 67 +++++++------------ pkg/sdk/logging/model/output/gelf_test.go | 4 +- .../model/output/zz_generated.deepcopy.go | 8 +-- 10 files changed, 64 insertions(+), 91 deletions(-) diff --git a/docs/configuration/crds/v1beta1/output_types.md b/docs/configuration/crds/v1beta1/output_types.md index 8f3bad24c..383e04768 100644 --- a/docs/configuration/crds/v1beta1/output_types.md +++ b/docs/configuration/crds/v1beta1/output_types.md @@ -32,7 +32,7 @@ OutputSpec defines the desired state of Output ### gcs (*output.GCSOutput, optional) {#outputspec-gcs} -### gelf (*output.GELFOutputConfig, optional) {#outputspec-gelf} +### gelf (*output.GelfOutputConfig, optional) {#outputspec-gelf} ### http (*output.HTTPOutputConfig, optional) {#outputspec-http} diff --git a/docs/configuration/plugins/_index.md b/docs/configuration/plugins/_index.md index a98ea919e..48433b2b8 100644 --- a/docs/configuration/plugins/_index.md +++ b/docs/configuration/plugins/_index.md @@ -38,7 +38,7 @@ For more information please click on the plugin name | **[Format rfc5424](outputs/format_rfc5424/)** | outputs | Specify how to format output record. | GA | [more info](https://github.com/cloudfoundry/fluent-plugin-syslog_rfc5424#format-section) | | **[Forward](outputs/forward/)** | outputs | Forwards events to other fluentd nodes. | GA | [more info](https://docs.fluentd.org/output/forward) | | **[Google Cloud Storage](outputs/gcs/)** | outputs | Store logs in Google Cloud Storage | GA | [0.4.0](https://github.com/kube-logging/fluent-plugin-gcs) | -| **[Gelf](outputs/gelf/)** | outputs | Output plugin writes events to GELF | Testing | [1.0.8](https://github.com/hotschedules/fluent-plugin-gelf-hs) | +| **[Gelf](outputs/gelf/)** | outputs | Output plugin writes logs to Graylog | Testing | [1.3.4](https://github.com/bmichalkiewicz/fluent-plugin-gelf-best) | | **[Http](outputs/http/)** | outputs | Sends logs to HTTP/HTTPS endpoints. | GA | [more info](https://docs.fluentd.org/output/http) | | **[Kafka](outputs/kafka/)** | outputs | Send your logs to Kafka | GA | [0.17.5](https://github.com/fluent/fluent-plugin-kafka/releases/tag/v0.17.5) | | **[Amazon Kinesis Firehose](outputs/kinesis_firehose/)** | outputs | Fluent plugin for Amazon Kinesis | Testing | [3.4.2](https://github.com/awslabs/aws-fluent-plugin-kinesis/releases/tag/v3.4.2) | diff --git a/docs/configuration/plugins/outputs/gelf.md b/docs/configuration/plugins/outputs/gelf.md index c6bdceb57..ed8107121 100644 --- a/docs/configuration/plugins/outputs/gelf.md +++ b/docs/configuration/plugins/outputs/gelf.md @@ -1,12 +1,22 @@ --- -title: GELF +title: Gelf weight: 200 generated_file: true --- -# [GELF Output](https://github.com/hotschedules/fluent-plugin-gelf-hs) +# Gelf output plugin for Fluentd ## Overview - Fluentd output plugin for GELF. + +For details, see [https://github.com/bmichalkiewicz/fluent-plugin-gelf-best](https://github.com/bmichalkiewicz/fluent-plugin-gelf-best). + +## Example +```yaml +spec: + gelf: + host: gelf-host + port: 12201 +``` + ## Configuration ## Output Config @@ -21,6 +31,12 @@ Available since ghcr.io/kube-logging/fluentd:v1.16-4.8-full [Buffer](../buffer/) Destination host +### max_bytes (int, optional) {#output config-max_bytes} + +MaxBytes specifies the maximum size, in bytes, of each individual log message. For details, see [https://github.com/Graylog2/graylog2-server/issues/873](https://github.com/Graylog2/graylog2-server/issues/873) + +Default: 3200 + ### port (int, required) {#output config-port} Destination host port @@ -34,42 +50,14 @@ Default: "udp" ### tls (*bool, optional) {#output config-tls} -Enable TlS +Enable TLS Default: false ### tls_options (map[string]string, optional) {#output config-tls_options} -TLS options . - -Default: {}). For details, see [https://github.com/graylog-labs/gelf-rb/blob/72916932b789f7a6768c3cdd6ab69a3c942dbcef/lib/gelf/transport/tcp_tls.rb#L7-L12](https://github.com/graylog-labs/gelf-rb/blob/72916932b789f7a6768c3cdd6ab69a3c942dbcef/lib/gelf/transport/tcp_tls.rb#L7-L12 +TLS Options. For details, see [https://github.com/graylog-labs/gelf-rb/blob/72916932b789f7a6768c3cdd6ab69a3c942dbcef/lib/gelf/transport/tcp_tls.rb#L7-L12](https://github.com/graylog-labs/gelf-rb/blob/72916932b789f7a6768c3cdd6ab69a3c942dbcef/lib/gelf/transport/tcp_tls.rb#L7-L12). +Default: {} - -## Example `GELF` output configurations - -{{< highlight yaml >}} -apiVersion: logging.banzaicloud.io/v1beta1 -kind: Output -metadata: - name: gelf-output-sample -spec: - gelf: - host: gelf-host - port: 12201 -{{}} - -Fluentd config result: - -{{< highlight xml >}} - - @type gelf - @id test_gelf - host gelf-host - port 12201 - -{{}} - - ---- diff --git a/pkg/sdk/logging/api/v1alpha1/output_types.go b/pkg/sdk/logging/api/v1alpha1/output_types.go index 850be9eb1..a38bdcfd7 100644 --- a/pkg/sdk/logging/api/v1alpha1/output_types.go +++ b/pkg/sdk/logging/api/v1alpha1/output_types.go @@ -54,7 +54,7 @@ type OutputSpec struct { AwsElasticsearchOutputConfig *output.AwsElasticsearchOutputConfig `json:"awsElasticsearch,omitempty"` RedisOutputConfig *output.RedisOutputConfig `json:"redis,omitempty"` SyslogOutputConfig *output.SyslogOutputConfig `json:"syslog,omitempty"` - GELFOutputConfig *output.GELFOutputConfig `json:"gelf,omitempty"` + GelfOutputConfig *output.GelfOutputConfig `json:"gelf,omitempty"` SQSOutputConfig *output.SQSOutputConfig `json:"sqs,omitempty"` RelabelOutputConfig *output.RelabelOutputConfig `json:"relabel,omitempty"` } diff --git a/pkg/sdk/logging/api/v1alpha1/zz_generated.deepcopy.go b/pkg/sdk/logging/api/v1alpha1/zz_generated.deepcopy.go index 91fd13168..0641a19a4 100644 --- a/pkg/sdk/logging/api/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/sdk/logging/api/v1alpha1/zz_generated.deepcopy.go @@ -466,9 +466,9 @@ func (in *OutputSpec) DeepCopyInto(out *OutputSpec) { *out = new(output.SyslogOutputConfig) (*in).DeepCopyInto(*out) } - if in.GELFOutputConfig != nil { - in, out := &in.GELFOutputConfig, &out.GELFOutputConfig - *out = new(output.GELFOutputConfig) + if in.GelfOutputConfig != nil { + in, out := &in.GelfOutputConfig, &out.GelfOutputConfig + *out = new(output.GelfOutputConfig) (*in).DeepCopyInto(*out) } if in.SQSOutputConfig != nil { diff --git a/pkg/sdk/logging/api/v1beta1/output_types.go b/pkg/sdk/logging/api/v1beta1/output_types.go index f18218b7b..b29412304 100644 --- a/pkg/sdk/logging/api/v1beta1/output_types.go +++ b/pkg/sdk/logging/api/v1beta1/output_types.go @@ -56,7 +56,7 @@ type OutputSpec struct { AwsElasticsearchOutputConfig *output.AwsElasticsearchOutputConfig `json:"awsElasticsearch,omitempty"` RedisOutputConfig *output.RedisOutputConfig `json:"redis,omitempty"` SyslogOutputConfig *output.SyslogOutputConfig `json:"syslog,omitempty"` - GELFOutputConfig *output.GELFOutputConfig `json:"gelf,omitempty"` + GelfOutputConfig *output.GelfOutputConfig `json:"gelf,omitempty"` SQSOutputConfig *output.SQSOutputConfig `json:"sqs,omitempty"` MattermostOutputConfig *output.MattermostOutputConfig `json:"mattermost,omitempty"` RelabelOutputConfig *output.RelabelOutputConfig `json:"relabel,omitempty"` diff --git a/pkg/sdk/logging/api/v1beta1/zz_generated.deepcopy.go b/pkg/sdk/logging/api/v1beta1/zz_generated.deepcopy.go index 1c7ad7ad6..f79257568 100644 --- a/pkg/sdk/logging/api/v1beta1/zz_generated.deepcopy.go +++ b/pkg/sdk/logging/api/v1beta1/zz_generated.deepcopy.go @@ -2538,9 +2538,9 @@ func (in *OutputSpec) DeepCopyInto(out *OutputSpec) { *out = new(output.SyslogOutputConfig) (*in).DeepCopyInto(*out) } - if in.GELFOutputConfig != nil { - in, out := &in.GELFOutputConfig, &out.GELFOutputConfig - *out = new(output.GELFOutputConfig) + if in.GelfOutputConfig != nil { + in, out := &in.GelfOutputConfig, &out.GelfOutputConfig + *out = new(output.GelfOutputConfig) (*in).DeepCopyInto(*out) } if in.SQSOutputConfig != nil { diff --git a/pkg/sdk/logging/model/output/gelf.go b/pkg/sdk/logging/model/output/gelf.go index f33501392..e2302c73c 100644 --- a/pkg/sdk/logging/model/output/gelf.go +++ b/pkg/sdk/logging/model/output/gelf.go @@ -20,69 +20,54 @@ import ( "github.com/kube-logging/logging-operator/pkg/sdk/logging/model/types" ) -// +name:"GELF" +// +name:"Gelf" // +weight:"200" -type _hugoGELF interface{} //nolint:deadcode,unused +type _hugoGelf interface{} //nolint:deadcode,unused -// +kubebuilder:object:generate=true -// +docName:"[GELF Output](https://github.com/hotschedules/fluent-plugin-gelf-hs)" -// Fluentd output plugin for GELF. -type _docGELF interface{} //nolint:deadcode,unused +// +docName:"Gelf output plugin for Fluentd" +/* +For details, see [https://github.com/bmichalkiewicz/fluent-plugin-gelf-best](https://github.com/bmichalkiewicz/fluent-plugin-gelf-best). + +## Example +```yaml +spec: + gelf: + host: gelf-host + port: 12201 +``` +*/ +type _docGelf interface{} //nolint:deadcode,unused // +name:"Gelf" -// +url:"https://github.com/hotschedules/fluent-plugin-gelf-hs" -// +version:"1.0.8" -// +description:"Output plugin writes events to GELF" +// +url:"https://github.com/bmichalkiewicz/fluent-plugin-gelf-best" +// +version:"1.3.4" +// +description:"Output plugin writes logs to Graylog" // +status:"Testing" type _metaGelf interface{} //nolint:deadcode,unused // +kubebuilder:object:generate=true // +docName:"Output Config" -type GELFOutputConfig struct { +type GelfOutputConfig struct { // Destination host Host string `json:"host"` // Destination host port Port int `json:"port"` // Transport Protocol (default: "udp") Protocol string `json:"protocol,omitempty"` - // Enable TlS (default: false) + // Enable TLS (default: false) TLS *bool `json:"tls,omitempty"` - // TLS options (default: {}). For details, see [https://github.com/graylog-labs/gelf-rb/blob/72916932b789f7a6768c3cdd6ab69a3c942dbcef/lib/gelf/transport/tcp_tls.rb#L7-L12](https://github.com/graylog-labs/gelf-rb/blob/72916932b789f7a6768c3cdd6ab69a3c942dbcef/lib/gelf/transport/tcp_tls.rb#L7-L12). + // TLS Options. + // For details, see [https://github.com/graylog-labs/gelf-rb/blob/72916932b789f7a6768c3cdd6ab69a3c942dbcef/lib/gelf/transport/tcp_tls.rb#L7-L12](https://github.com/graylog-labs/gelf-rb/blob/72916932b789f7a6768c3cdd6ab69a3c942dbcef/lib/gelf/transport/tcp_tls.rb#L7-L12). (default: {}) TLSOptions map[string]string `json:"tls_options,omitempty"` + // MaxBytes specifies the maximum size, in bytes, of each individual log message. + // For details, see [https://github.com/Graylog2/graylog2-server/issues/873](https://github.com/Graylog2/graylog2-server/issues/873) (default: 3200) + MaxBytes int `json:"max_bytes,omitempty"` // Available since ghcr.io/kube-logging/fluentd:v1.16-4.8-full // +docLink:"Buffer,../buffer/" Buffer *Buffer `json:"buffer,omitempty"` } -// -/* -## Example `GELF` output configurations - -{{< highlight yaml >}} -apiVersion: logging.banzaicloud.io/v1beta1 -kind: Output -metadata: - name: gelf-output-sample -spec: - gelf: - host: gelf-host - port: 12201 -{{}} - -Fluentd config result: - -{{< highlight xml >}} - - @type gelf - @id test_gelf - host gelf-host - port 12201 - -{{}} -*/ -type _expGELF interface{} //nolint:deadcode,unused - -func (s *GELFOutputConfig) ToDirective(secretLoader secret.SecretLoader, id string) (types.Directive, error) { +func (s *GelfOutputConfig) ToDirective(secretLoader secret.SecretLoader, id string) (types.Directive, error) { pluginType := "gelf" gelf := &types.OutputPlugin{ PluginMeta: types.PluginMeta{ diff --git a/pkg/sdk/logging/model/output/gelf_test.go b/pkg/sdk/logging/model/output/gelf_test.go index 25543efe4..a37af588d 100644 --- a/pkg/sdk/logging/model/output/gelf_test.go +++ b/pkg/sdk/logging/model/output/gelf_test.go @@ -23,7 +23,7 @@ import ( "sigs.k8s.io/yaml" ) -func TestGELFOutputConfig(t *testing.T) { +func TestGelfOutputConfig(t *testing.T) { CONFIG := []byte(` host: gelf-host port: 12201 @@ -43,7 +43,7 @@ port: 12201 ` - s := &output.GELFOutputConfig{} + s := &output.GelfOutputConfig{} require.NoError(t, yaml.Unmarshal(CONFIG, s)) test := render.NewOutputPluginTest(t, s) test.DiffResult(expected) diff --git a/pkg/sdk/logging/model/output/zz_generated.deepcopy.go b/pkg/sdk/logging/model/output/zz_generated.deepcopy.go index 49c6f85ba..7a3c15b34 100644 --- a/pkg/sdk/logging/model/output/zz_generated.deepcopy.go +++ b/pkg/sdk/logging/model/output/zz_generated.deepcopy.go @@ -566,7 +566,7 @@ func (in *GCSOutput) DeepCopy() *GCSOutput { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GELFOutputConfig) DeepCopyInto(out *GELFOutputConfig) { +func (in *GelfOutputConfig) DeepCopyInto(out *GelfOutputConfig) { *out = *in if in.TLS != nil { in, out := &in.TLS, &out.TLS @@ -587,12 +587,12 @@ func (in *GELFOutputConfig) DeepCopyInto(out *GELFOutputConfig) { } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GELFOutputConfig. -func (in *GELFOutputConfig) DeepCopy() *GELFOutputConfig { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GelfOutputConfig. +func (in *GelfOutputConfig) DeepCopy() *GelfOutputConfig { if in == nil { return nil } - out := new(GELFOutputConfig) + out := new(GelfOutputConfig) in.DeepCopyInto(out) return out } From f7396e98116bff8ad0b3be5dc620d68dc11a36c2 Mon Sep 17 00:00:00 2001 From: Bartosz Date: Thu, 12 Sep 2024 10:06:26 +0200 Subject: [PATCH 3/4] docs: add version information for feature availability Signed-off-by: Bartosz --- docs/configuration/plugins/outputs/gelf.md | 2 +- pkg/sdk/logging/model/output/gelf.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/configuration/plugins/outputs/gelf.md b/docs/configuration/plugins/outputs/gelf.md index ed8107121..25f1793f2 100644 --- a/docs/configuration/plugins/outputs/gelf.md +++ b/docs/configuration/plugins/outputs/gelf.md @@ -33,7 +33,7 @@ Destination host ### max_bytes (int, optional) {#output config-max_bytes} -MaxBytes specifies the maximum size, in bytes, of each individual log message. For details, see [https://github.com/Graylog2/graylog2-server/issues/873](https://github.com/Graylog2/graylog2-server/issues/873) +MaxBytes specifies the maximum size, in bytes, of each individual log message. For details, see [https://github.com/Graylog2/graylog2-server/issues/873](https://github.com/Graylog2/graylog2-server/issues/873) Available since ghcr.io/kube-logging/fluentd:v1.16-4.10-full Default: 3200 diff --git a/pkg/sdk/logging/model/output/gelf.go b/pkg/sdk/logging/model/output/gelf.go index e2302c73c..8e688dc55 100644 --- a/pkg/sdk/logging/model/output/gelf.go +++ b/pkg/sdk/logging/model/output/gelf.go @@ -60,7 +60,8 @@ type GelfOutputConfig struct { // For details, see [https://github.com/graylog-labs/gelf-rb/blob/72916932b789f7a6768c3cdd6ab69a3c942dbcef/lib/gelf/transport/tcp_tls.rb#L7-L12](https://github.com/graylog-labs/gelf-rb/blob/72916932b789f7a6768c3cdd6ab69a3c942dbcef/lib/gelf/transport/tcp_tls.rb#L7-L12). (default: {}) TLSOptions map[string]string `json:"tls_options,omitempty"` // MaxBytes specifies the maximum size, in bytes, of each individual log message. - // For details, see [https://github.com/Graylog2/graylog2-server/issues/873](https://github.com/Graylog2/graylog2-server/issues/873) (default: 3200) + // For details, see [https://github.com/Graylog2/graylog2-server/issues/873](https://github.com/Graylog2/graylog2-server/issues/873) + // Available since ghcr.io/kube-logging/fluentd:v1.16-4.10-full (default: 3200) MaxBytes int `json:"max_bytes,omitempty"` // Available since ghcr.io/kube-logging/fluentd:v1.16-4.8-full // +docLink:"Buffer,../buffer/" From cd12738ba0f53b414fdbf9cd9c601701fc43893b Mon Sep 17 00:00:00 2001 From: Bartosz Date: Thu, 12 Sep 2024 10:17:18 +0200 Subject: [PATCH 4/4] fix(ci): check-diff Signed-off-by: Bartosz --- pkg/sdk/logging/model/output/gelf.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/sdk/logging/model/output/gelf.go b/pkg/sdk/logging/model/output/gelf.go index 8e688dc55..3d90adb51 100644 --- a/pkg/sdk/logging/model/output/gelf.go +++ b/pkg/sdk/logging/model/output/gelf.go @@ -61,7 +61,7 @@ type GelfOutputConfig struct { TLSOptions map[string]string `json:"tls_options,omitempty"` // MaxBytes specifies the maximum size, in bytes, of each individual log message. // For details, see [https://github.com/Graylog2/graylog2-server/issues/873](https://github.com/Graylog2/graylog2-server/issues/873) - // Available since ghcr.io/kube-logging/fluentd:v1.16-4.10-full (default: 3200) + // Available since ghcr.io/kube-logging/fluentd:v1.16-4.10-full (default: 3200) MaxBytes int `json:"max_bytes,omitempty"` // Available since ghcr.io/kube-logging/fluentd:v1.16-4.8-full // +docLink:"Buffer,../buffer/"