From fd389e600a981865f7ce983939eb63a51446d783 Mon Sep 17 00:00:00 2001 From: Bence Csati <113284287+csatib02@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:51:44 +0100 Subject: [PATCH] fix: fluentd prom metrics invalid addr (#1891) Signed-off-by: Bence Csati --- pkg/resources/fluentbit/config.go | 2 +- pkg/resources/fluentbit/configsecret.go | 10 +++++----- pkg/resources/fluentd/config.go | 18 +++++++----------- pkg/resources/fluentd/configsecret.go | 15 ++++++++------- 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/pkg/resources/fluentbit/config.go b/pkg/resources/fluentbit/config.go index 15d02c5e2..59af4d120 100644 --- a/pkg/resources/fluentbit/config.go +++ b/pkg/resources/fluentbit/config.go @@ -38,7 +38,7 @@ var fluentBitConfigTemplate = ` Coro_Stack_Size {{ .CoroStackSize }} {{- if .Monitor.Enabled }} HTTP_Server On - {{- if .EnabledIPv6 }} + {{- if .Monitor.EnabledIPv6 }} HTTP_Listen [::] {{- else }} Listen 0.0.0.0 diff --git a/pkg/resources/fluentbit/configsecret.go b/pkg/resources/fluentbit/configsecret.go index ad5e418d8..ede0e2587 100644 --- a/pkg/resources/fluentbit/configsecret.go +++ b/pkg/resources/fluentbit/configsecret.go @@ -60,14 +60,14 @@ type upstream struct { type fluentBitConfig struct { Namespace string Monitor struct { - Enabled bool - Port int32 - Path string + Enabled bool + Port int32 + EnabledIPv6 bool + Path string } Flush int32 Grace int32 LogLevel string - EnabledIPv6 bool CoroStackSize int32 Output map[string]string ForceHotReloadAfterGrace bool @@ -219,7 +219,6 @@ func (r *Reconciler) configSecret() (runtime.Object, reconciler.DesiredState, er Grace: r.fluentbitSpec.Grace, ForceHotReloadAfterGrace: r.fluentbitSpec.ForceHotReloadAfterGrace, LogLevel: r.fluentbitSpec.LogLevel, - EnabledIPv6: r.fluentbitSpec.EnabledIPv6, CoroStackSize: r.fluentbitSpec.CoroStackSize, Namespace: r.Logging.Spec.ControlNamespace, DisableKubernetesFilter: disableKubernetesFilter, @@ -236,6 +235,7 @@ func (r *Reconciler) configSecret() (runtime.Object, reconciler.DesiredState, er if r.fluentbitSpec.Metrics != nil { input.Monitor.Enabled = true input.Monitor.Port = r.fluentbitSpec.Metrics.Port + input.Monitor.EnabledIPv6 = r.fluentbitSpec.EnabledIPv6 input.Monitor.Path = r.fluentbitSpec.Metrics.Path } diff --git a/pkg/resources/fluentd/config.go b/pkg/resources/fluentd/config.go index 49496bd26..433ddef31 100644 --- a/pkg/resources/fluentd/config.go +++ b/pkg/resources/fluentd/config.go @@ -58,22 +58,18 @@ var fluentdInputTemplate = ` {{ if .Monitor.Enabled }} @type prometheus - port {{ .Monitor.Port }} -{{- if .Monitor.Path }} - metrics_path {{ .Monitor.Path }} -{{- end }} - -{{- if .EnabledIPv6 }} - - @type prometheus + {{- if .Monitor.EnabledIPv6 }} @id in_prometheus6 bind "::" + {{- else }} + bind "0.0.0.0" + {{- end }} port {{ .Monitor.Port }} -{{- if .Monitor.Path }} + {{- if .Monitor.Path }} metrics_path {{ .Monitor.Path }} -{{- end }} + {{- end }} -{{- end }} + @type prometheus_monitor diff --git a/pkg/resources/fluentd/configsecret.go b/pkg/resources/fluentd/configsecret.go index 2dee35fcd..4d7e3932e 100644 --- a/pkg/resources/fluentd/configsecret.go +++ b/pkg/resources/fluentd/configsecret.go @@ -27,13 +27,13 @@ import ( ) type fluentdConfig struct { - LogFormat string - LogLevel string - EnabledIPv6 bool - Monitor struct { - Enabled bool - Port int32 - Path string + LogFormat string + LogLevel string + Monitor struct { + Enabled bool + Port int32 + EnabledIPv6 bool + Path string } IgnoreSameLogInterval string IgnoreRepeatedLogInterval string @@ -73,6 +73,7 @@ func (r *Reconciler) generateConfigSecret(fluentdSpec v1beta1.FluentdSpec) (map[ if fluentdSpec.Metrics != nil { input.Monitor.Enabled = true input.Monitor.Port = fluentdSpec.Metrics.Port + input.Monitor.EnabledIPv6 = fluentdSpec.EnabledIPv6 input.Monitor.Path = fluentdSpec.Metrics.Path }