Skip to content

Commit

Permalink
fix: fluentd prom metrics invalid addr (#1891)
Browse files Browse the repository at this point in the history
Signed-off-by: Bence Csati <bence.csati@axoflow.com>
  • Loading branch information
csatib02 authored Dec 18, 2024
1 parent 6978331 commit fd389e6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pkg/resources/fluentbit/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions pkg/resources/fluentbit/configsecret.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
}

Expand Down
18 changes: 7 additions & 11 deletions pkg/resources/fluentd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,18 @@ var fluentdInputTemplate = `
{{ if .Monitor.Enabled }}
<source>
@type prometheus
port {{ .Monitor.Port }}
{{- if .Monitor.Path }}
metrics_path {{ .Monitor.Path }}
{{- end }}
</source>
{{- if .EnabledIPv6 }}
<source>
@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 }}
</source>
{{- end }}
<source>
@type prometheus_monitor
</source>
Expand Down
15 changes: 8 additions & 7 deletions pkg/resources/fluentd/configsecret.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit fd389e6

Please sign in to comment.