[bitnami/fluentd] Fluentd doesn't send logs to elasticsearch
Which chart: bitnami/fluentd:4.4.1
Describe the bug Fluentd doesn't send container logs to a bitnami/elasticsearch+bitnami/kibana stack - "pattern not matched"
2021-11-03 20:36:53 +0000 [warn]: #0 pattern not matched: "2021-11-03T20:36:53.573339263Z stdout F 10.42.1.1 - - [03/Nov/2021:20:36:53 +0000] \"GET /wp-login.php HTTP/1.1\" 200 6106"
2021-11-03 20:36:53 +0000 [warn]: #0 pattern not matched: "2021-11-03T20:36:53.587312078Z stdout F 10.42.1.1 - - [03/Nov/2021:20:36:53 +0000] \"GET /wp-admin/install.php HTTP/1.1\" 200 1293"
2021-11-03 20:37:03 +0000 [warn]: #0 pattern not matched: "2021-11-03T20:37:03.569906955Z stdout F 10.42.1.1 - - [03/Nov/2021:20:37:03 +0000] \"GET /wp-login.php HTTP/1.1\" 200 6106"
2021-11-03 20:37:03 +0000 [warn]: #0 pattern not matched: "2021-11-03T20:37:03.587280878Z stdout F 10.42.1.1 - - [03/Nov/2021:20:37:03 +0000] \"GET /wp-admin/install.php HTTP/1.1\" 200 1293"
2021-11-03 20:37:13 +0000 [warn]: #0 pattern not matched: "2021-11-03T20:37:13.571902841Z stdout F 10.42.1.1 - - [03/Nov/2021:20:37:13 +0000] \"GET /wp-login.php HTTP/1.1\" 200 6106"
2021-11-03 20:37:13 +0000 [warn]: #0 pattern not matched: "2021-11-03T20:37:13.584724236Z stdout F 10.42.1.1 - - [03/Nov/2021:20:37:13 +0000] \"GET /wp-admin/install.php HTTP/1.1\" 200 1293"
2021-11-03 20:37:23 +0000 [warn]: #0 pattern not matched: "2021-11-03T20:37:23.57052274Z stdout F 10.42.1.1 - - [03/Nov/2021:20:37:23 +0000] \"GET /wp-login.php HTTP/1.1\" 200 6106"
2021-11-03 20:37:23 +0000 [warn]: #0 pattern not matched: "2021-11-03T20:37:23.588541589Z stdout F 10.42.1.1 - - [03/Nov/2021:20:37:23 +0000] \"GET /wp-admin/install.php HTTP/1.1\" 200 1293"
To Reproduce Steps to reproduce the behavior:
- Prepare a config map file based on the provided in the chart confingmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: fluentd-configmap
data:
fluentd.conf: |
# Prometheus Exporter Plugin
# input plugin that exports metrics
<source>
@type prometheus
port 24231
</source>
# input plugin that collects metrics from MonitorAgent
<source>
@type prometheus_monitor
<labels>
host ${hostname}
</labels>
</source>
# input plugin that collects metrics for output plugin
<source>
@type prometheus_output_monitor
<labels>
host ${hostname}
</labels>
</source>
# Ignore fluentd own events
<match fluent.**>
@type null
</match>
# TCP input to receive logs from the forwarders
<source>
@type forward
bind 0.0.0.0
port 24224
</source>
# HTTP input for the liveness and readiness probes
<source>
@type http
bind 0.0.0.0
port 9880
</source>
# Throw the healthcheck to the standard output instead of forwarding it
<match fluentd.healthcheck>
@type stdout
</match>
# Send the logs to the standard output
<match **>
@type elasticsearch
include_tag_key true
host elasticsearch-1633095796-coordinating-only
port 9200
logstash_format true
<buffer>
@type file
path /opt/bitnami/fluentd/logs/buffers/logs.buffer
flush_thread_count 2
flush_interval 5s
</buffer>
</match>
kubectl apply -f manifests/fluentd-configmap.yamlhelm install fluentd bitnami/fluentd --set aggregator.configMap=fluentd-configmap- Deploy bitnami/wordpress for example and go through the pages to get some log
- See nothing has been parsed to Kibana
Expected behavior Not only the logs from Wordpress, but also from other pods
Version of Helm and Kubernetes:
- Output of
helm version:
version.BuildInfo{Version:"v3.7.0", GitCommit:"eeac83883cb4014fe60267ec6373570374ce770b", GitTreeState:"clean", GoVersion:"go1.16.8"}
- Output of
kubectl version:
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.5+k3s2", GitCommit:"724ef700bab896ff252a75e2be996d5f4ff1b842", GitTreeState:"clean", BuildDate:"2021-10-05T19:59:14Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.5+k3s2", GitCommit:"724ef700bab896ff252a75e2be996d5f4ff1b842", GitTreeState:"clean", BuildDate:"2021-10-05T19:59:14Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"linux/amd64"}
Additional context
However, a simple app like the one below somehow produces logs in Kibana, probably by directly sending logs to the headless service.
apiVersion: apps/v1
kind: Deployment
metadata:
name: helloworld
labels:
app: helloworld
spec:
replicas: 1
template:
metadata:
name: helloworld
labels:
app: helloworld
spec:
containers:
- name: helloworld
image: sergbs/django-hello-world:1
imagePullPolicy: Always
ports:
- containerPort: 8000
env:
- name: FLUENT_HOST
value: "fluentd-headless"
- name: FLUENT_PORT
value: "24224"
selector:
matchLabels:
app: helloworld
---
apiVersion: v1
kind: Service
metadata:
name: helloworld
spec:
selector:
app: helloworld
ports:
- port: 8000
nodePort: 30011
type: NodePort
Hi,
I'm missing in the initial configuration a section that matches the container logs in the host system, am I missing anything?
Hi,
I'm missing in the initial configuration a section that matches the container logs in the host system, am I missing anything?
Hello, thanks for the response.
Regarding the question:
-
First of all, I'd like to point out that everything is by default if it helps. In the beginning, I thought that everything should be working out of the box, since I went bitnami everything.
-
As far as I understand, in the chart you have few fluentd configs. Some are used by forwarders to collect the container logs and send them to aggregators.
i.e.
Here is the part of the config where container logs are collected:
...
<source>
@type tail
path /var/log/containers/*.log
# exclude Fluentd logs
exclude_path /var/log/containers/*fluentd*.log
pos_file /opt/bitnami/fluentd/logs/buffers/fluentd-docker.pos
tag kubernetes.*
read_from_head true
<parse>
@type json
time_key time
time_format %Y-%m-%dT%H:%M:%S.%NZ
</parse>
</source>
# enrich with kubernetes metadata
<filter kubernetes.**>
@type kubernetes_metadata
</filter>
...
Here those logs are sent to aggregators:
...
<match **>
@type forward
<server>
host fluentd-1636128830-0.fluentd-1636128830-headless.default.svc.cluster.local
port 24224
</server>
<buffer>
@type file
path /opt/bitnami/fluentd/logs/buffers/logs.buffer
flush_thread_count 2
flush_interval 5s
</buffer>
</match>
...
Here we finally go to the recommended config I posted. So, the logs are accepted by the aggregator here:
...
<source>
@type forward
bind 0.0.0.0
port 24224
</source>
...
And then sent to the elastic:
...
<match **>
@type elasticsearch
include_tag_key true
host elasticsearch-1633095796-coordinating-only
port 9200
logstash_format true
<buffer>
@type file
path /opt/bitnami/fluentd/logs/buffers/logs.buffer
flush_thread_count 2
flush_interval 5s
</buffer>
</match>
...
At least this is from my understanding.
Thank you so much for the information. I will need to work on reproducing it on my side. I will let you know my findings.
Hi,
I did the following steps
Deployed elasticsearch with kibana
helm install elastic bitnami/elasticsearch --set master.replicas=1 --set data.replicas=1 --set coordinating.replicas=1 --set global.kibanaEnabled=true
Then deployed this configmap
apiVersion: v1
kind: ConfigMap
metadata:
name: elasticsearch-output
data:
fluentd.conf: |
# Prometheus Exporter Plugin
# input plugin that exports metrics
<source>
@type prometheus
port 24231
</source>
# input plugin that collects metrics from MonitorAgent
<source>
@type prometheus_monitor
<labels>
host ${hostname}
</labels>
</source>
# input plugin that collects metrics for output plugin
<source>
@type prometheus_output_monitor
<labels>
host ${hostname}
</labels>
</source>
# Ignore fluentd own events
<match fluent.**>
@type null
</match>
# TCP input to receive logs from the forwarders
<source>
@type forward
bind 0.0.0.0
port 24224
</source>
# HTTP input for the liveness and readiness probes
<source>
@type http
bind 0.0.0.0
port 9880
</source>
# Throw the healthcheck to the standard output instead of forwarding it
<match fluentd.healthcheck>
@type stdout
</match>
# Send the logs to the standard output
<match **>
@type elasticsearch
include_tag_key true
host "#{ENV['ELASTICSEARCH_HOST']}"
port "#{ENV['ELASTICSEARCH_PORT']}"
logstash_format true
<buffer>
@type file
path /opt/bitnami/fluentd/logs/buffers/logs.buffer
flush_thread_count 2
flush_interval 5s
</buffer>
</match>
Then deployed fluentd
helm install fluentd bitnami/fluentd --set aggregator.configMap=elasticsearch-output --set aggregator.extraEnv[0].name=ELASTICSEARCH_HOST --set aggregator.extraEnv[0].value=elastic-coordinating-only --set aggregator.extraEnv[1].name=ELASTICSEARCH_PORT --set-string aggregator.extraEnv[1].value=9200
Then deployed WordPress
helm install wp bitnami/wordpress
When I checked Kibana, I could see entries for WordPress logs

Any idea of what could be different in your case?
Any idea of what could be different in your case?
Thank you so much for investigating the matter.
I decided to build a new cluster and execute exactly the commands you wrote - just to make sure. Unfortunately, with the same result - no log from Wordpress, while I still getting logs from the helloworld app (yaml of which I posted above). As the helloworld app sends logs directly to the headless Fluentd pod(and those are forwarded to kibana successfully), I have a feeling like daemonset pods just won't send their logs to the headless.
Regarding the possible differences between our setups: I use k3s (k3s version v1.21.5+k3s2 (724ef700)) as my Kubernetes provider. This shouldn't matter however I've had problems with starting elasticsearch pods once due to (apparently) a bug with a particular k3s version.
Maybe you could suggest some commands to further debug it? I know very little of how Fluentd works, not sure where to look and how to interpret its logs.
I'm afraid I don't have much expertise in Fluentd either to understand what the issue could be. In my case I'm using minikube, in case it helps. Could you try deploying another chart and see if there are log entries from this chart (different from wordpress)
This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.
Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.
@redmictian did you solve this? I am having the same problem.