Skip to content

Commit

Permalink
Merge pull request #1267 from cw-Guo/feat/input_udp
Browse files Browse the repository at this point in the history
feat(fluentbit): add fluentbit input_udp plugin
  • Loading branch information
benjaminhuo authored Jul 29, 2024
2 parents de6fb52 + 0ce06e9 commit 917f3c3
Show file tree
Hide file tree
Showing 10 changed files with 370 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apis/fluentbit/v1alpha2/clusterinput_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ type InputSpec struct {
Syslog *input.Syslog `json:"syslog,omitempty"`
// TCP defines the TCP input plugin configuration
TCP *input.TCP `json:"tcp,omitempty"`
// UDP defines the UDP input plugin configuration
UDP *input.UDP `json:"udp,omitempty"`
// KubernetesEvents defines the KubernetesEvents input plugin configuration
KubernetesEvents *input.KubernetesEvents `json:"kubernetesEvents,omitempty"`
// Processors defines the processors configuration
Expand Down
73 changes: 73 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/input/udp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package input

import (
"fmt"
"github.com/fluent/fluent-operator/v2/apis/fluentbit/v1alpha2/plugins"
"github.com/fluent/fluent-operator/v2/apis/fluentbit/v1alpha2/plugins/params"
)

// +kubebuilder:object:generate:=true

// The udp input plugin allows to retrieve structured JSON or raw messages over a UDP network interface (UDP port).
// **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/udp**

type UDP struct {
// Listen Listener network interface, default: 0.0.0.0
Listen *string `json:"listen,omitempty"`
// Port Specify the UDP port where listening for connections, default: 5170
// +kubebuilder:validation:Minimum:=1
// +kubebuilder:validation:Maximum:=65535
Port *int32 `json:"port,omitempty"`
// BufferSize Specify the maximum buffer size in KB to receive a JSON message.
// If not set, the default size will be the value of Chunk_Size.
// +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$"
BufferSize *string `json:"bufferSize,omitempty"`
// By default the buffer to store the incoming JSON messages, do not allocate the maximum memory allowed,
// instead it allocate memory when is required.
// The rounds of allocations are set by Chunk_Size in KB. If not set, Chunk_Size is equal to 32 (32KB).
// +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$"
ChunkSize *string `json:"chunkSize,omitempty"`
// Format Specify the expected payload format. It support the options json and none.
// When using json, it expects JSON maps, when is set to none,
// it will split every record using the defined Separator (option below).
Format *string `json:"format,omitempty"`
// Separator When the expected Format is set to none, Fluent Bit needs a separator string to split the records. By default it uses the breakline character (LF or 0x10).
Separator *string `json:"separator,omitempty"`
// SourceAddressKey Specify the key where the source address will be injected.
SourceAddressKey *string `json:"sourceAddressKey,omitempty"`
// Threaded mechanism allows input plugin to run in a separate thread which helps to desaturate the main pipeline.
Threaded *string `json:"threaded,omitempty"`
}

func (_ *UDP) Name() string {
return "udp"
}

func (u *UDP) Params(_ plugins.SecretLoader) (*params.KVs, error) {
kvs := params.NewKVs()
if u.Listen != nil {
kvs.Insert("Listen", *u.Listen)
}
if u.Port != nil {
kvs.Insert("Port", fmt.Sprint(*u.Port))
}
if u.BufferSize != nil {
kvs.Insert("Buffer_Size", *u.BufferSize)
}
if u.ChunkSize != nil {
kvs.Insert("Chunk_Size", *u.ChunkSize)
}
if u.Format != nil {
kvs.Insert("Format", *u.Format)
}
if u.Separator != nil {
kvs.Insert("Separator", *u.Separator)
}
if u.SourceAddressKey != nil {
kvs.Insert("Source_Address_Key", *u.SourceAddressKey)
}
if u.Threaded != nil {
kvs.Insert("Threaded", *u.Threaded)
}
return kvs, nil
}
70 changes: 70 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions apis/fluentbit/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,52 @@ spec:
uses the breakline character (LF or 0x10).
type: string
type: object
udp:
description: UDP defines the UDP input plugin configuration
properties:
bufferSize:
description: |-
BufferSize Specify the maximum buffer size in KB to receive a JSON message.
If not set, the default size will be the value of Chunk_Size.
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
chunkSize:
description: |-
By default the buffer to store the incoming JSON messages, do not allocate the maximum memory allowed,
instead it allocate memory when is required.
The rounds of allocations are set by Chunk_Size in KB. If not set, Chunk_Size is equal to 32 (32KB).
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
format:
description: |-
Format Specify the expected payload format. It support the options json and none.
When using json, it expects JSON maps, when is set to none,
it will split every record using the defined Separator (option below).
type: string
listen:
description: 'Listen Listener network interface, default: 0.0.0.0'
type: string
port:
description: 'Port Specify the UDP port where listening for connections,
default: 5170'
format: int32
maximum: 65535
minimum: 1
type: integer
separator:
description: Separator When the expected Format is set to none,
Fluent Bit needs a separator string to split the records. By
default it uses the breakline character (LF or 0x10).
type: string
sourceAddressKey:
description: SourceAddressKey Specify the key where the source
address will be injected.
type: string
threaded:
description: Threaded mechanism allows input plugin to run in
a separate thread which helps to desaturate the main pipeline.
type: string
type: object
type: object
type: object
served: true
Expand Down
46 changes: 46 additions & 0 deletions config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,52 @@ spec:
uses the breakline character (LF or 0x10).
type: string
type: object
udp:
description: UDP defines the UDP input plugin configuration
properties:
bufferSize:
description: |-
BufferSize Specify the maximum buffer size in KB to receive a JSON message.
If not set, the default size will be the value of Chunk_Size.
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
chunkSize:
description: |-
By default the buffer to store the incoming JSON messages, do not allocate the maximum memory allowed,
instead it allocate memory when is required.
The rounds of allocations are set by Chunk_Size in KB. If not set, Chunk_Size is equal to 32 (32KB).
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
format:
description: |-
Format Specify the expected payload format. It support the options json and none.
When using json, it expects JSON maps, when is set to none,
it will split every record using the defined Separator (option below).
type: string
listen:
description: 'Listen Listener network interface, default: 0.0.0.0'
type: string
port:
description: 'Port Specify the UDP port where listening for connections,
default: 5170'
format: int32
maximum: 65535
minimum: 1
type: integer
separator:
description: Separator When the expected Format is set to none,
Fluent Bit needs a separator string to split the records. By
default it uses the breakline character (LF or 0x10).
type: string
sourceAddressKey:
description: SourceAddressKey Specify the key where the source
address will be injected.
type: string
threaded:
description: Threaded mechanism allows input plugin to run in
a separate thread which helps to desaturate the main pipeline.
type: string
type: object
type: object
type: object
served: true
Expand Down
1 change: 1 addition & 0 deletions docs/fluentbit.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ InputSpec defines the desired state of ClusterInput
| nginx | Nginx defines the Nginx input plugin configuration | *[input.Nginx](plugins/input/nginx.md) |
| syslog | Syslog defines the Syslog input plugin configuration | *[input.Syslog](plugins/input/syslog.md) |
| tcp | TCP defines the TCP input plugin configuration | *[input.TCP](plugins/input/tcp.md) |
| udp | UDP defines the UDP input plugin configuration | *[input.UDP](plugins/input/udp.md) |
| kubernetesEvents | KubernetesEvents defines the KubernetesEvents input plugin configuration | *[input.KubernetesEvents](plugins/input/kubernetesevents.md) |
| processors | Processors defines the processors configuration | *plugins.Config |

Expand Down
15 changes: 15 additions & 0 deletions docs/plugins/fluentbit/input/udp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# UDP




| Field | Description | Scheme |
| ----- | ----------- | ------ |
| listen | Listen Listener network interface, default: 0.0.0.0 | *string |
| port | Port Specify the UDP port where listening for connections, default: 5170 | *int32 |
| bufferSize | BufferSize Specify the maximum buffer size in KB to receive a JSON message. If not set, the default size will be the value of Chunk_Size. | *string |
| chunkSize | By default the buffer to store the incoming JSON messages, do not allocate the maximum memory allowed, instead it allocate memory when is required. The rounds of allocations are set by Chunk_Size in KB. If not set, Chunk_Size is equal to 32 (32KB). | *string |
| format | Format Specify the expected payload format. It support the options json and none. When using json, it expects JSON maps, when is set to none, it will split every record using the defined Separator (option below). | *string |
| separator | Separator When the expected Format is set to none, Fluent Bit needs a separator string to split the records. By default it uses the breakline character (LF or 0x10). | *string |
| sourceAddressKey | SourceAddressKey Specify the key where the source address will be injected. | *string |
| threaded | Threaded mechanism allows input plugin to run in a separate thread which helps to desaturate the main pipeline. | *string |
46 changes: 46 additions & 0 deletions manifests/setup/fluent-operator-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2794,6 +2794,52 @@ spec:
uses the breakline character (LF or 0x10).
type: string
type: object
udp:
description: UDP defines the UDP input plugin configuration
properties:
bufferSize:
description: |-
BufferSize Specify the maximum buffer size in KB to receive a JSON message.
If not set, the default size will be the value of Chunk_Size.
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
chunkSize:
description: |-
By default the buffer to store the incoming JSON messages, do not allocate the maximum memory allowed,
instead it allocate memory when is required.
The rounds of allocations are set by Chunk_Size in KB. If not set, Chunk_Size is equal to 32 (32KB).
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
format:
description: |-
Format Specify the expected payload format. It support the options json and none.
When using json, it expects JSON maps, when is set to none,
it will split every record using the defined Separator (option below).
type: string
listen:
description: 'Listen Listener network interface, default: 0.0.0.0'
type: string
port:
description: 'Port Specify the UDP port where listening for connections,
default: 5170'
format: int32
maximum: 65535
minimum: 1
type: integer
separator:
description: Separator When the expected Format is set to none,
Fluent Bit needs a separator string to split the records. By
default it uses the breakline character (LF or 0x10).
type: string
sourceAddressKey:
description: SourceAddressKey Specify the key where the source
address will be injected.
type: string
threaded:
description: Threaded mechanism allows input plugin to run in
a separate thread which helps to desaturate the main pipeline.
type: string
type: object
type: object
type: object
served: true
Expand Down
Loading

0 comments on commit 917f3c3

Please sign in to comment.