Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fluentd prom metrics invalid addr #1891

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading