Skip to content

Commit 84a3076

Browse files
authored
feat(fluentbit): add support for multiline_buffer_limit configuration to FluentBitConfig and ClusterFluentBitConfig (#1877)
Signed-off-by: Dylan Jenik <dylanjenikcodes@gmail.com>
1 parent 8bd2ce0 commit 84a3076

9 files changed

Lines changed: 88 additions & 0 deletions

apis/fluentbit/v1alpha2/clusterfluentbitconfig_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ type Service struct {
126126
SchedulerBase *int32 `json:"schedulerBase,omitempty"`
127127
// Set a maximum retry time in seconds for the scheduler. Supported in Fluent Bit >= 1.8.7
128128
SchedulerCap *int32 `json:"schedulerCap,omitempty"`
129+
// Set a default buffer size limit for multiline parsers. The value must be according to the Unit Size specification.
130+
// +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$"
131+
MultilineBufferLimit string `json:"multilineBufferLimit,omitempty"`
129132
}
130133

131134
// +kubebuilder:object:root=true
@@ -243,6 +246,9 @@ func (s *Service) Params() *params.KVs {
243246
if s.SchedulerCap != nil {
244247
m.Insert("scheduler.cap", fmt.Sprint(*s.SchedulerCap))
245248
}
249+
if s.MultilineBufferLimit != "" {
250+
m.Insert("multiline_buffer_limit", s.MultilineBufferLimit)
251+
}
246252
return m
247253
}
248254

apis/fluentbit/v1alpha2/clusterfluentbitconfig_types_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,47 @@ func TestRenderMainConfigK8sInYaml(t *testing.T) {
11841184
g.Expect(yamlConfig).To(Equal(expectedK8sYamlWithClusterFilterOutput))
11851185
}
11861186

1187+
func TestClusterFluentBitConfig_Service_MultilineBufferLimit(t *testing.T) {
1188+
g := NewGomegaWithT(t)
1189+
sl := plugins.NewSecretLoader(nil, "testnamespace")
1190+
1191+
cfbc := ClusterFluentBitConfig{
1192+
Spec: FluentBitConfigSpec{
1193+
Service: &Service{
1194+
Daemon: utils.ToPtr(false),
1195+
FlushSeconds: utils.ToPtr[float64](1),
1196+
MultilineBufferLimit: "5MB",
1197+
},
1198+
},
1199+
}
1200+
1201+
expectedClassic := `[Service]
1202+
Daemon false
1203+
Flush 1
1204+
multiline_buffer_limit 5MB
1205+
`
1206+
expectedYamlFmt := `service:
1207+
daemon: false
1208+
flush: 1
1209+
multiline_buffer_limit: 5MB
1210+
pipeline:
1211+
inputs:
1212+
outputs:
1213+
`
1214+
1215+
config, err := cfbc.RenderMainConfig(
1216+
sl, ClusterInputList{}, ClusterFilterList{}, ClusterOutputList{}, nil, nil, nil,
1217+
)
1218+
g.Expect(err).NotTo(HaveOccurred())
1219+
g.Expect(config).To(Equal(expectedClassic))
1220+
1221+
yamlConfig, err := cfbc.RenderMainConfigInYaml(
1222+
sl, ClusterInputList{}, ClusterFilterList{}, ClusterOutputList{}, nil, nil, nil,
1223+
)
1224+
g.Expect(err).NotTo(HaveOccurred())
1225+
g.Expect(yamlConfig).To(Equal(expectedYamlFmt))
1226+
}
1227+
11871228
func TestClusterFluentBitConfig_RenderMainConfig_WithParsersFiles(t *testing.T) {
11881229
g := NewGomegaWithT(t)
11891230
sl := plugins.NewSecretLoader(nil, "testnamespace")

charts/fluent-bit-crds/templates/fluentbit.fluent.io_clusterfluentbitconfigs.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,11 @@ spec:
372372
- debug
373373
- trace
374374
type: string
375+
multilineBufferLimit:
376+
description: Set a default buffer size limit for multiline parsers.
377+
The value must be according to the Unit Size specification.
378+
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
379+
type: string
375380
parsersFile:
376381
description: Optional 'parsers' config file (can be multiple)
377382
type: string

charts/fluent-bit-crds/templates/fluentbit.fluent.io_fluentbitconfigs.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,11 @@ spec:
404404
- debug
405405
- trace
406406
type: string
407+
multilineBufferLimit:
408+
description: Set a default buffer size limit for multiline parsers.
409+
The value must be according to the Unit Size specification.
410+
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
411+
type: string
407412
parsersFile:
408413
description: Optional 'parsers' config file (can be multiple)
409414
type: string

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,11 @@ spec:
369369
- debug
370370
- trace
371371
type: string
372+
multilineBufferLimit:
373+
description: Set a default buffer size limit for multiline parsers.
374+
The value must be according to the Unit Size specification.
375+
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
376+
type: string
372377
parsersFile:
373378
description: Optional 'parsers' config file (can be multiple)
374379
type: string

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,11 @@ spec:
401401
- debug
402402
- trace
403403
type: string
404+
multilineBufferLimit:
405+
description: Set a default buffer size limit for multiline parsers.
406+
The value must be according to the Unit Size specification.
407+
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
408+
type: string
404409
parsersFile:
405410
description: Optional 'parsers' config file (can be multiple)
406411
type: string

docs/fluentbit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ ParserSpec defines the desired state of ClusterParser
646646
| hotReload | If true enable reloading via HTTP | *bool |
647647
| schedulerBase | Set a base for exponential backoff in the scheduler. Supported in Fluent Bit >= 1.8.7 | *int32 |
648648
| schedulerCap | Set a maximum retry time in seconds for the scheduler. Supported in Fluent Bit >= 1.8.7 | *int32 |
649+
| multilineBufferLimit | Set a default buffer size limit for multiline parsers. The value must be according to the Unit Size specification. | string |
649650

650651
[Back to TOC](#table-of-contents)
651652
# Storage

manifests/setup/fluent-operator-crd.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,6 +1830,11 @@ spec:
18301830
- debug
18311831
- trace
18321832
type: string
1833+
multilineBufferLimit:
1834+
description: Set a default buffer size limit for multiline parsers.
1835+
The value must be according to the Unit Size specification.
1836+
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
1837+
type: string
18331838
parsersFile:
18341839
description: Optional 'parsers' config file (can be multiple)
18351840
type: string
@@ -17082,6 +17087,11 @@ spec:
1708217087
- debug
1708317088
- trace
1708417089
type: string
17090+
multilineBufferLimit:
17091+
description: Set a default buffer size limit for multiline parsers.
17092+
The value must be according to the Unit Size specification.
17093+
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
17094+
type: string
1708517095
parsersFile:
1708617096
description: Optional 'parsers' config file (can be multiple)
1708717097
type: string

manifests/setup/setup.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,6 +1830,11 @@ spec:
18301830
- debug
18311831
- trace
18321832
type: string
1833+
multilineBufferLimit:
1834+
description: Set a default buffer size limit for multiline parsers.
1835+
The value must be according to the Unit Size specification.
1836+
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
1837+
type: string
18331838
parsersFile:
18341839
description: Optional 'parsers' config file (can be multiple)
18351840
type: string
@@ -17082,6 +17087,11 @@ spec:
1708217087
- debug
1708317088
- trace
1708417089
type: string
17090+
multilineBufferLimit:
17091+
description: Set a default buffer size limit for multiline parsers.
17092+
The value must be according to the Unit Size specification.
17093+
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
17094+
type: string
1708517095
parsersFile:
1708617096
description: Optional 'parsers' config file (can be multiple)
1708717097
type: string

0 commit comments

Comments
 (0)