Skip to content

Commit e4ee681

Browse files
committed
make lua scripts code and script not required
Signed-off-by: Onecer <[email protected]>
1 parent 8c05b8d commit e4ee681

13 files changed

+89
-20
lines changed

apis/fluentbit/v1alpha2/plugins/filter/lua_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package filter
22

33
import (
4+
"regexp"
45
"strconv"
56
"strings"
6-
"regexp"
77

88
"github.com/fluent/fluent-operator/v2/apis/fluentbit/v1alpha2/plugins"
99
"github.com/fluent/fluent-operator/v2/apis/fluentbit/v1alpha2/plugins/params"
@@ -17,12 +17,12 @@ import (
1717
type Lua struct {
1818
plugins.CommonParams `json:",inline"`
1919
// Path to the Lua script that will be used.
20-
Script v1.ConfigMapKeySelector `json:"script"`
20+
Script v1.ConfigMapKeySelector `json:"script,omitempty"`
2121
// Lua function name that will be triggered to do filtering.
2222
// It's assumed that the function is declared inside the Script defined above.
2323
Call string `json:"call"`
2424
// Inline LUA code instead of loading from a path via script.
25-
Code string `json:"code"`
25+
Code string `json:"code,omitempty"`
2626
// If these keys are matched, the fields are converted to integer.
2727
// If more than one key, delimit by space.
2828
// Note that starting from Fluent Bit v1.6 integer data types are preserved

charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterfilters.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,6 @@ spec:
345345
type: array
346346
required:
347347
- call
348-
- code
349-
- script
350348
type: object
351349
modify:
352350
description: Modify defines Modify Filter configuration.

charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_filters.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,6 @@ spec:
345345
type: array
346346
required:
347347
- call
348-
- code
349-
- script
350348
type: object
351349
modify:
352350
description: Modify defines Modify Filter configuration.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- if .Values.Kubernetes -}}
2+
{{- if .Values.fluentbit.enable -}}
3+
{{- if .Values.fluentbit.filter.multiline.enable -}}
4+
apiVersion: fluentbit.fluent.io/v1alpha2
5+
kind: ClusterFilter
6+
metadata:
7+
name: multiline
8+
labels:
9+
fluentbit.fluent.io/enabled: "true"
10+
fluentbit.fluent.io/component: logging
11+
spec:
12+
match: kube.*
13+
filters:
14+
- multiline:
15+
keyContent: {{ .Values.fluentbit.filter.multiline.keyContent | quote }}
16+
parser: "{{- join "," .Values.fluentbit.filter.multiline.parsers -}}"
17+
{{- end }}
18+
{{- end }}
19+
{{- end }}

charts/fluent-operator/templates/fluentbit-clusterinput-tail.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ spec:
2020
{{- else if eq .Values.containerRuntime "crio" }}
2121
parser: cri
2222
{{- end }}
23+
{{- if .Values.fluentbit.input.tail.multilineParser }}
24+
multilineParser: {{ .Values.fluentbit.input.tail.multilineParser | quote }}
25+
{{- end }}
2326
refreshIntervalSeconds: {{ .Values.fluentbit.input.tail.refreshIntervalSeconds }}
2427
memBufLimit: {{ .Values.fluentbit.input.tail.memBufLimit }}
2528
{{- if .Values.fluentbit.input.tail.bufferMaxSize }}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{- if .Values.Kubernetes -}}
2+
{{- if .Values.fluentbit.enable -}}
3+
{{- if .Values.fluentbit.parsers.javaMultiline.enable -}}
4+
apiVersion: fluentbit.fluent.io/v1alpha2
5+
kind: ClusterMultilineParser
6+
metadata:
7+
name: java-multiline
8+
labels:
9+
fluentbit.fluent.io/enabled: "true"
10+
fluentbit.fluent.io/component: logging
11+
spec:
12+
type: "regex"
13+
flushTimeout: 1000
14+
keyContent: "log"
15+
rules:
16+
- start: "start_state"
17+
regex: '/\[?(\d+\-\d+\-\d+ \d+\:\d+\:\d+(\.\d+)?)\]? /'
18+
next: "cont"
19+
- start: "cont"
20+
regex: '/^(?!\[?\d+\-\d+\-\d+).*/'
21+
next: "cont"
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}

charts/fluent-operator/templates/fluentbitconfig-fluentBitConfig.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ metadata:
88
app.kubernetes.io/name: fluent-bit
99
spec:
1010
service:
11-
parsersFile: parsers.conf
11+
parsersFiles:
12+
- /fluent-bit/config/parsers.conf
13+
- /fluent-bit/config/parsers_multiline.conf
1214
httpServer: true
1315
{{- if .Values.fluentbit.logLevel }}
1416
logLevel: {{ .Values.fluentbit.logLevel }}
@@ -29,5 +31,8 @@ spec:
2931
outputSelector:
3032
matchLabels:
3133
fluentbit.fluent.io/enabled: "true"
34+
multilineParserSelector:
35+
matchLabels:
36+
fluentbit.fluent.io/enabled: "true"
3237
{{- end }}
3338
{{- end }}

charts/fluent-operator/values.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ fluentbit:
183183
# Use storageType as "filesystem" if you want to use filesystem as the buffering mechanism for tail input.
184184
storageType: memory
185185
pauseOnChunksOverlimit: "off"
186+
# multiline.parser
187+
# multilineParser: "docker, cri"
186188
systemd:
187189
enable: true
188190
systemdFilter:
@@ -319,6 +321,15 @@ fluentbit:
319321
# Configure the default filters in FluentBit.
320322
# The `filter` will filter and parse the collected log information and output the logs into a uniform format. You can choose whether to turn this on or not.
321323
filter:
324+
multiline:
325+
enable: false
326+
keyContent: log
327+
parsers:
328+
- go
329+
- python
330+
- java
331+
# use custom multiline parser need set .Values.parsers.javaMultiline.enable = true
332+
# - java-multiline
322333
kubernetes:
323334
enable: true
324335
labels: false
@@ -342,6 +353,11 @@ fluentbit:
342353
# removes the hostPath mounts for varlibcontainers, varlogs and systemd.
343354
disableLogVolumes: false
344355

356+
parsers:
357+
javaMultiline:
358+
# use in filter for parser generic springboot multiline log format
359+
enable: false
360+
345361
fluentd:
346362
# Installs a sub chart carrying the CRDs for the fluentd controller. The sub chart is enabled by default.
347363
crdsEnable: true

config/crd/bases/fluentbit.fluent.io_clusterfilters.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,6 @@ spec:
345345
type: array
346346
required:
347347
- call
348-
- code
349-
- script
350348
type: object
351349
modify:
352350
description: Modify defines Modify Filter configuration.

config/crd/bases/fluentbit.fluent.io_filters.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,6 @@ spec:
345345
type: array
346346
required:
347347
- call
348-
- code
349-
- script
350348
type: object
351349
modify:
352350
description: Modify defines Modify Filter configuration.

0 commit comments

Comments
 (0)