{{- if and .Values.forwarder.enabled (not .Values.forwarder.configMap) -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "fluentd.fullname" . }}-forwarder-cm
labels: {{- include "fluentd.labels" . | nindent 4 }}
app.kubernetes.io/component: forwarder
data:
fluentd.conf: |
{{- if .Values.metrics.enabled -}}
# Prometheus Exporter Plugin
# input plugin that exports metrics
# input plugin that collects metrics from MonitorAgent
# input plugin that collects metrics for output plugin
# input plugin that collects metrics for in_tail plugin
{{- end }}
# Ignore fluentd own events
@type null
# HTTP input for the liveness and readiness probes
# Throw the healthcheck to the standard output instead of forwarding it
@type stdout
# Get the logs from the containers running in the node
# enrich with kubernetes metadata
@type kubernetes_metadata
{{ if .Values.aggregator.enabled }}
# Forward all logs to the aggregators
@type forward
{{- $fullName := (include "fluentd.fullname" .) }}
{{- $global := . }}
{{- $domain := default "cluster.local" .Values.clusterDomain }}
{{- $port := .Values.aggregator.port | int }}
{{- range $i, $e := until (.Values.aggregator.replicaCount | int) }}
{{ printf "host %s-%d.%s-headless.%s.svc.%s" $fullName $i $fullName $global.Release.Namespace $domain }}
{{ printf "port %d" $port }}
{{- if ne $i 0 }}
standby
{{- end }}
{{- end}}
@type file
path /opt/bitnami/fluentd/logs/buffers/logs.buffer
flush_thread_count 2
flush_interval 5s
{{- else }}
# Send the logs to the standard output
@type stdout
{{- end -}}
{{- end -}}