Switch from fluentd to fluentbit for log forwarding (#1086)
This removes fluentd in favor of using fluentbit, which is lighter (in memory usage) and seems to be more actively maintained. Fluentbit's config file format is different from fluentd's. It also doesn't support the same record modification stuff that fluentd supports, so we have to change the influxdb query slightly. This means that after an upgrade, the new CLI may won't work for querying older logs. Hopefully, this slight breakage is acceptable; if users really need older logs they can use the older CLI.
This commit is contained in:
committed by
Ta-Ching Chen
parent
0fc864f230
commit
4e4c8aa14f
+3
-2
@@ -71,8 +71,9 @@ Parameter | Description | Default
|
||||
--------- | ----------- | -------
|
||||
`createNamespace` | If true, create `fission-function` and `fission-builder` namespaces | ` true`
|
||||
`logger.influxdbAdmin` | Log database admin username | `admin`
|
||||
`logger.fluentdImage` | Logger fluentd image | `fission/fluentd`
|
||||
`logger.fluentdImageTag` | Fission ui image tag | `1.0.0`
|
||||
`logger.fluentdImageRepository` | Logger fluentbit image repository | `index.docker.io`
|
||||
`logger.fluentdImage` | Logger fluentbit image | `fluent/fluent-bit`
|
||||
`logger.fluentdImageTag` | Logger fluentbit image tag | `1.0.4`
|
||||
`nats.enabled` | Nats streaming enabled | `true`
|
||||
`nats.authToken` | Nats streaming auth token | `defaultFissionAuthToken`
|
||||
`nats.clusterID` | Nats streaming clusterID | `fissionMQTrigger`
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
# Some stuff in this file is copied out of https://github.com/fluent/fluent-bit-kubernetes-logging/blob/master/output/kafka/fluent-bit-configmap.yaml
|
||||
[SERVICE]
|
||||
Flush 5
|
||||
Log_Level info
|
||||
Parsers_File parsers.conf
|
||||
|
||||
[INPUT]
|
||||
Name tail
|
||||
Tag log.*
|
||||
Path ${LOG_PATH}
|
||||
Mem_Buf_Limit 5MB
|
||||
Parser docker
|
||||
DB /var/log/fission/flb_kube.db
|
||||
Skip_Long_Lines On
|
||||
Refresh_Interval 10
|
||||
|
||||
[FILTER]
|
||||
Name kubernetes
|
||||
Match log.*
|
||||
Kube_URL https://kubernetes.default.svc.cluster.local:443
|
||||
|
||||
#
|
||||
# Flatten kubernetes labels so we can tag and query functionuid with influxdb
|
||||
#
|
||||
[FILTER]
|
||||
Name nest
|
||||
Match log.*
|
||||
Operation lift
|
||||
Nested_under kubernetes
|
||||
Prefix_with kubernetes_
|
||||
|
||||
[FILTER]
|
||||
Name nest
|
||||
Match log.*
|
||||
Operation lift
|
||||
Nested_under kubernetes_labels
|
||||
Prefix_with kubernetes_labels_
|
||||
|
||||
[OUTPUT]
|
||||
Name influxdb
|
||||
Match log.*
|
||||
Host ${INFLUXDB_ADDRESS}
|
||||
Port ${INFLUXDB_PORT}
|
||||
Database ${INFLUXDB_DBNAME}
|
||||
HTTP_User ${INFLUXDB_USERNAME}
|
||||
HTTP_Passwd ${INFLUXDB_PASSWD}
|
||||
Tag_Keys kubernetes_labels_functionUid
|
||||
Sequence_Tag _seq
|
||||
|
||||
|
||||
# Useful for testing config changes
|
||||
#[OUTPUT]
|
||||
# Name file
|
||||
# Match log.*
|
||||
# Path /flbout.txt
|
||||
@@ -1,59 +0,0 @@
|
||||
# Hide all fluent-related logs
|
||||
<match fluent.**>
|
||||
type null
|
||||
</match>
|
||||
|
||||
# Collect all logs from the containers in the current namespace
|
||||
<source>
|
||||
type tail
|
||||
format json
|
||||
time_key time
|
||||
path "#{ENV['FLUENTD_PATH']}"
|
||||
time_format %Y-%m-%dT%H:%M:%S.%NZ
|
||||
tag fission.*
|
||||
read_from_head true
|
||||
refresh_interval 5
|
||||
</source>
|
||||
|
||||
# Augment logs with Kubernetes metadata
|
||||
<filter fission.**>
|
||||
type kubernetes_metadata
|
||||
</filter>
|
||||
|
||||
# Simplify the nested objects to XX_YY_ZZ names
|
||||
<filter fission.**>
|
||||
type flatten_hash
|
||||
separator _
|
||||
</filter>
|
||||
|
||||
# Add `funcuid` to the record (using the functionUid label)
|
||||
<match fission.**>
|
||||
type record_reformer
|
||||
enable_ruby false
|
||||
tag log
|
||||
<record>
|
||||
funcuid ${kubernetes_labels_functionUid}
|
||||
</record>
|
||||
</match>
|
||||
|
||||
# Push logs into influxdb
|
||||
<match **>
|
||||
@type influxdb
|
||||
host "#{ENV['INFLUXDB_ADDRESS']}"
|
||||
port "#{ENV['INFLUXDB_PORT']}"
|
||||
dbname "#{ENV['INFLUXDB_DBNAME']}"
|
||||
user "#{ENV['INFLUXDB_USERNAME']}"
|
||||
password "#{ENV['INFLUXDB_PASSWD']}"
|
||||
use_ssl false
|
||||
time_precision ns
|
||||
tag_keys ["funcuid"]
|
||||
sequence_tag _seq
|
||||
buffer_type file
|
||||
buffer_path /var/log/fission/fluentd.buffer
|
||||
buffer_chunk_limit 128m
|
||||
buffer_queue_limit 256
|
||||
flush_interval 5
|
||||
retry_limit 10
|
||||
retry_wait 1.0
|
||||
num_threads 2
|
||||
</match>
|
||||
@@ -0,0 +1,12 @@
|
||||
[PARSER]
|
||||
Name docker
|
||||
Format json
|
||||
Time_Key time
|
||||
Time_Format %Y-%m-%dT%H:%M:%S.%L
|
||||
Time_Keep On
|
||||
|
||||
# next bit is useful when the logs from the function itself are in json
|
||||
# Command | Decoder | Field | Optional Action
|
||||
# =============|==================|=================
|
||||
#Decode_Field_As escaped log
|
||||
|
||||
+39
-19
@@ -1,15 +1,21 @@
|
||||
# Fluentd deployment for Fission
|
||||
# Fluentbit deployment for Fission
|
||||
#
|
||||
# Requires:
|
||||
# - service account: fission-svc
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-fission-fluentd
|
||||
name: {{ .Release.Name }}-fission-fluentbit
|
||||
data:
|
||||
{{- if .Files.Get "config/fluentd.conf" }}
|
||||
td-agent.conf: |
|
||||
{{ .Files.Get "config/fluentd.conf" | indent 3 }}
|
||||
{{- if .Files.Get "config/fluentbit.conf" }}
|
||||
fluentbit.conf: |
|
||||
{{ .Files.Get "config/fluentbit.conf" | indent 3 }}
|
||||
{{ else }}
|
||||
{{ fail "invalid chart" }}
|
||||
{{- end }}
|
||||
{{- if .Files.Get "config/parsers.conf" }}
|
||||
parsers.conf: |
|
||||
{{ .Files.Get "config/parsers.conf" | indent 3 }}
|
||||
{{ else }}
|
||||
{{ fail "invalid chart" }}
|
||||
{{- end }}
|
||||
@@ -27,9 +33,29 @@ spec:
|
||||
svc: logger
|
||||
spec:
|
||||
containers:
|
||||
- name: fluentd
|
||||
- name: logger
|
||||
image: "{{ .Values.repository }}/{{ .Values.image }}:{{ .Values.imageTag }}"
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
apiVersion: v1
|
||||
fieldPath: spec.nodeName
|
||||
command: ["/fission-bundle"]
|
||||
args: ["--logger"]
|
||||
volumeMounts:
|
||||
- name: container-log
|
||||
mountPath: /var/log/
|
||||
readOnly: false
|
||||
- name: docker-log
|
||||
mountPath: /var/lib/docker/containers
|
||||
readOnly: true
|
||||
- name: fluentbit
|
||||
image: "{{ .Values.logger.fluentdImageRepository }}/{{ .Values.logger.fluentdImage }}:{{ .Values.logger.fluentdImageTag }}"
|
||||
imagePullPolicy: {{ .Values.pullPolicy }}
|
||||
# CMD ["/fluent-bit/bin/fluent-bit", "-c", "/fluent-bit/etc/fluent-bit.conf"]
|
||||
command: ["/fluent-bit/bin/fluent-bit", "-c", "/fluent-bit/etc/fluentbit.conf"]
|
||||
env:
|
||||
- name: INFLUXDB_ADDRESS
|
||||
value: influxdb
|
||||
@@ -47,8 +73,8 @@ spec:
|
||||
secretKeyRef:
|
||||
name: influxdb
|
||||
key: password
|
||||
- name: FLUENTD_PATH
|
||||
value: /var/log/containers/*{{.Values.functionNamespace}}*.log
|
||||
- name: LOG_PATH
|
||||
value: /var/log/fission/*.log
|
||||
volumeMounts:
|
||||
- name: container-log
|
||||
mountPath: /var/log/
|
||||
@@ -56,11 +82,8 @@ spec:
|
||||
- name: docker-log
|
||||
mountPath: /var/lib/docker/containers
|
||||
readOnly: true
|
||||
- name: fission-log
|
||||
mountPath: /var/log/fission
|
||||
readOnly: false
|
||||
- name: fluentd-config
|
||||
mountPath: /etc/td-agent/
|
||||
- name: fluentbit-config
|
||||
mountPath: /fluent-bit/etc/
|
||||
readOnly: true
|
||||
serviceAccount: fission-svc
|
||||
volumes:
|
||||
@@ -70,12 +93,9 @@ spec:
|
||||
- name: docker-log
|
||||
hostPath:
|
||||
path: /var/lib/docker/containers
|
||||
- name: fission-log
|
||||
hostPath:
|
||||
path: /var/log/fission
|
||||
# Fluentd config location: /etc/td-agent/td-agent.conf
|
||||
- name: fluentd-config
|
||||
# Fluentbit config location: /fluent-bit/etc/*.conf
|
||||
- name: fluentbit-config
|
||||
configMap:
|
||||
name: {{ .Release.Name }}-fission-fluentd
|
||||
name: {{ .Release.Name }}-fission-fluentbit
|
||||
updateStrategy:
|
||||
type: RollingUpdate
|
||||
@@ -54,8 +54,8 @@ enableIstio: false
|
||||
logger:
|
||||
influxdbAdmin: "admin"
|
||||
fluentdImageRepository: index.docker.io
|
||||
fluentdImage: fission/fluentd
|
||||
fluentdImageTag: 1.0.0
|
||||
fluentdImage: fluent/fluent-bit
|
||||
fluentdImageTag: 1.0.4
|
||||
|
||||
## Message queue trigger config
|
||||
### NATS Streaming, enabled by default
|
||||
@@ -139,4 +139,4 @@ canaryDeployment:
|
||||
|
||||
# Use these flags to enable opentracing, the variable is endpoint of Jaeger collector in the format shown below
|
||||
#traceCollectorEndpoint: "http://jaeger-collector.jaeger.svc:14268/api/traces?format=jaeger.thrift"
|
||||
#traceSamplingRate: 0.75
|
||||
#traceSamplingRate: 0.75
|
||||
|
||||
Reference in New Issue
Block a user