Skip to content

Commit

Permalink
Merge pull request fluent#931 from sjliu1/syslog
Browse files Browse the repository at this point in the history
[summerospp]add fluentbit syslog plugin
  • Loading branch information
benjaminhuo authored Sep 21, 2023
2 parents 33e09d2 + ed46fdd commit da22f5e
Show file tree
Hide file tree
Showing 10 changed files with 395 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 @@ -67,6 +67,8 @@ type InputSpec struct {
StatsD *input.StatsD `json:"statsd,omitempty"`
// Nginx defines the Nginx input plugin configuration
Nginx *input.Nginx `json:"nginx,omitempty"`
// Syslog defines the Syslog input plugin configuration
Syslog *input.Syslog `json:"syslog,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
85 changes: 85 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/input/syslog.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
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

// Syslog input plugins allows to collect Syslog messages through a Unix socket server (UDP or TCP) or over the network using TCP or UDP. <br />
// **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/syslog**
type Syslog struct {
// Defines transport protocol mode: unix_udp (UDP over Unix socket), unix_tcp (TCP over Unix socket), tcp or udp
// +kubebuilder:validation:Enum:=unix_udp;unix_tcp;tcp;udp
Mode string `json:"mode,omitempty"`
// If Mode is set to tcp or udp, specify the network interface to bind, default: 0.0.0.0
Listen string `json:"listen,omitempty"`
// If Mode is set to tcp or udp, specify the TCP port to listen for incoming connections.
// +kubebuilder:validation:Minimum:=1
// +kubebuilder:validation:Maximum:=65535
Port *int32 `json:"port,omitempty"`
// If Mode is set to unix_tcp or unix_udp, set the absolute path to the Unix socket file.
Path string `json:"path,omitempty"`
// If Mode is set to unix_tcp or unix_udp, set the permission of the Unix socket file, default: 0644
UnixPerm *int32 `json:"unixPerm,omitempty"`
// Specify an alternative parser for the message. If Mode is set to tcp or udp then the default parser is syslog-rfc5424 otherwise syslog-rfc3164-local is used.
// If your syslog messages have fractional seconds set this Parser value to syslog-rfc5424 instead.
Parser string `json:"parser,omitempty"`
// By default the buffer to store the incoming Syslog messages, do not allocate the maximum memory allowed, instead it allocate memory when is required.
//The rounds of allocations are set by Buffer_Chunk_Size. If not set, Buffer_Chunk_Size is equal to 32000 bytes (32KB).
// +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$"
BufferChunkSize string `json:"bufferChunkSize,omitempty"`
// Specify the maximum buffer size to receive a Syslog message. If not set, the default size will be the value of Buffer_Chunk_Size.
// +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$"
BufferMaxSize string `json:"bufferMaxSize,omitempty"`
// Specify the maximum socket receive buffer size. If not set, the default value is OS-dependant,
// but generally too low to accept thousands of syslog messages per second without loss on udp or unix_udp sockets. Note that on Linux the value is capped by sysctl net.core.rmem_max.
// +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$"
ReceiveBufferSize string `json:"receiveBufferSize,omitempty"`
// Specify the key where the source address will be injected.
SourceAddressKey string `json:"sourceAddressKey,omitempty"`
}

func (_ *Syslog) Name() string {
return "syslog"
}

func (s *Syslog) Params(_ plugins.SecretLoader) (*params.KVs, error) {
kvs := params.NewKVs()

if s.Mode != "" {
kvs.Insert("Mode", s.Path)
}
if s.Listen != "" {
kvs.Insert("Listen", s.Path)
}
if s.Port != nil {
kvs.Insert("Port", fmt.Sprint(*s.Port))
}
if s.Path != "" {
kvs.Insert("Path", s.Path)
}
if s.UnixPerm != nil {
kvs.Insert("Unix_Perm", fmt.Sprint(*s.UnixPerm))
}
if s.Parser != "" {
kvs.Insert("Parser", s.Parser)
}
if s.BufferChunkSize != "" {
kvs.Insert("Buffer_Chunk_Size", s.BufferChunkSize)
}
if s.BufferMaxSize != "" {
kvs.Insert("Buffer_Max_Size", s.BufferChunkSize)
}
if s.ReceiveBufferSize != "" {
kvs.Insert("Receive_Buffer_Size", s.ReceiveBufferSize)
}
if s.SourceAddressKey != "" {
kvs.Insert("Source_Address_Key", s.SourceAddressKey)
}

return kvs, nil
}
25 changes: 25 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 @@ -389,6 +389,71 @@ spec:
minimum: 1
type: integer
type: object
syslog:
description: Syslog defines the Syslog input plugin configuration
properties:
bufferChunkSize:
description: By default the buffer to store the incoming Syslog
messages, do not allocate the maximum memory allowed, instead
it allocate memory when is required. The rounds of allocations
are set by Buffer_Chunk_Size. If not set, Buffer_Chunk_Size
is equal to 32000 bytes (32KB).
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
bufferMaxSize:
description: Specify the maximum buffer size to receive a Syslog
message. If not set, the default size will be the value of Buffer_Chunk_Size.
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
listen:
description: 'If Mode is set to tcp or udp, specify the network
interface to bind, default: 0.0.0.0'
type: string
mode:
description: 'Defines transport protocol mode: unix_udp (UDP over
Unix socket), unix_tcp (TCP over Unix socket), tcp or udp'
enum:
- unix_udp
- unix_tcp
- tcp
- udp
type: string
parser:
description: Specify an alternative parser for the message. If
Mode is set to tcp or udp then the default parser is syslog-rfc5424
otherwise syslog-rfc3164-local is used. If your syslog messages
have fractional seconds set this Parser value to syslog-rfc5424
instead.
type: string
path:
description: If Mode is set to unix_tcp or unix_udp, set the absolute
path to the Unix socket file.
type: string
port:
description: If Mode is set to tcp or udp, specify the TCP port
to listen for incoming connections.
format: int32
maximum: 65535
minimum: 1
type: integer
receiveBufferSize:
description: Specify the maximum socket receive buffer size. If
not set, the default value is OS-dependant, but generally too
low to accept thousands of syslog messages per second without
loss on udp or unix_udp sockets. Note that on Linux the value
is capped by sysctl net.core.rmem_max.
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
sourceAddressKey:
description: Specify the key where the source address will be
injected.
type: string
unixPerm:
description: 'If Mode is set to unix_tcp or unix_udp, set the
permission of the Unix socket file, default: 0644'
format: int32
type: integer
type: object
systemd:
description: Systemd defines Systemd Input configuration.
properties:
Expand Down
65 changes: 65 additions & 0 deletions config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,71 @@ spec:
minimum: 1
type: integer
type: object
syslog:
description: Syslog defines the Syslog input plugin configuration
properties:
bufferChunkSize:
description: By default the buffer to store the incoming Syslog
messages, do not allocate the maximum memory allowed, instead
it allocate memory when is required. The rounds of allocations
are set by Buffer_Chunk_Size. If not set, Buffer_Chunk_Size
is equal to 32000 bytes (32KB).
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
bufferMaxSize:
description: Specify the maximum buffer size to receive a Syslog
message. If not set, the default size will be the value of Buffer_Chunk_Size.
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
listen:
description: 'If Mode is set to tcp or udp, specify the network
interface to bind, default: 0.0.0.0'
type: string
mode:
description: 'Defines transport protocol mode: unix_udp (UDP over
Unix socket), unix_tcp (TCP over Unix socket), tcp or udp'
enum:
- unix_udp
- unix_tcp
- tcp
- udp
type: string
parser:
description: Specify an alternative parser for the message. If
Mode is set to tcp or udp then the default parser is syslog-rfc5424
otherwise syslog-rfc3164-local is used. If your syslog messages
have fractional seconds set this Parser value to syslog-rfc5424
instead.
type: string
path:
description: If Mode is set to unix_tcp or unix_udp, set the absolute
path to the Unix socket file.
type: string
port:
description: If Mode is set to tcp or udp, specify the TCP port
to listen for incoming connections.
format: int32
maximum: 65535
minimum: 1
type: integer
receiveBufferSize:
description: Specify the maximum socket receive buffer size. If
not set, the default value is OS-dependant, but generally too
low to accept thousands of syslog messages per second without
loss on udp or unix_udp sockets. Note that on Linux the value
is capped by sysctl net.core.rmem_max.
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
sourceAddressKey:
description: Specify the key where the source address will be
injected.
type: string
unixPerm:
description: 'If Mode is set to unix_tcp or unix_udp, set the
permission of the Unix socket file, default: 0644'
format: int32
type: integer
type: object
systemd:
description: Systemd defines Systemd Input configuration.
properties:
Expand Down
1 change: 1 addition & 0 deletions docs/fluentbit.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ InputSpec defines the desired state of ClusterInput
| collectd | Collectd defines the Collectd input plugin configuration | *[input.Collectd](plugins/input/collectd.md) |
| statsd | StatsD defines the StatsD input plugin configuration | *[input.StatsD](plugins/input/statsd.md) |
| 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) |

[Back to TOC](#table-of-contents)
# NamespacedFluentBitCfgSpec
Expand Down
17 changes: 17 additions & 0 deletions docs/plugins/fluentbit/input/syslog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Syslog

Syslog input plugins allows to collect Syslog messages through a Unix socket server (UDP or TCP) or over the network using TCP or UDP. <br /> **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/syslog**


| Field | Description | Scheme |
| ----- | ----------- | ------ |
| mode | Defines transport protocol mode: unix_udp (UDP over Unix socket), unix_tcp (TCP over Unix socket), tcp or udp | string |
| listen | If Mode is set to tcp or udp, specify the network interface to bind, default: 0.0.0.0 | string |
| port | If Mode is set to tcp or udp, specify the TCP port to listen for incoming connections. | *int32 |
| path | If Mode is set to unix_tcp or unix_udp, set the absolute path to the Unix socket file. | string |
| unixPerm | If Mode is set to unix_tcp or unix_udp, set the permission of the Unix socket file, default: 0644 | *int32 |
| parser | Specify an alternative parser for the message. If Mode is set to tcp or udp then the default parser is syslog-rfc5424 otherwise syslog-rfc3164-local is used. If your syslog messages have fractional seconds set this Parser value to syslog-rfc5424 instead. | string |
| bufferChunkSize | By default the buffer to store the incoming Syslog messages, do not allocate the maximum memory allowed, instead it allocate memory when is required. The rounds of allocations are set by Buffer_Chunk_Size. If not set, Buffer_Chunk_Size is equal to 32000 bytes (32KB). | string |
| bufferMaxSize | Specify the maximum buffer size to receive a Syslog message. If not set, the default size will be the value of Buffer_Chunk_Size. | string |
| receiveBufferSize | Specify the maximum socket receive buffer size. If not set, the default value is OS-dependant, but generally too low to accept thousands of syslog messages per second without loss on udp or unix_udp sockets. Note that on Linux the value is capped by sysctl net.core.rmem_max. | string |
| sourceAddressKey | Specify the key where the source address will be injected. | string |
65 changes: 65 additions & 0 deletions manifests/setup/fluent-operator-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2138,6 +2138,71 @@ spec:
minimum: 1
type: integer
type: object
syslog:
description: Syslog defines the Syslog input plugin configuration
properties:
bufferChunkSize:
description: By default the buffer to store the incoming Syslog
messages, do not allocate the maximum memory allowed, instead
it allocate memory when is required. The rounds of allocations
are set by Buffer_Chunk_Size. If not set, Buffer_Chunk_Size
is equal to 32000 bytes (32KB).
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
bufferMaxSize:
description: Specify the maximum buffer size to receive a Syslog
message. If not set, the default size will be the value of Buffer_Chunk_Size.
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
listen:
description: 'If Mode is set to tcp or udp, specify the network
interface to bind, default: 0.0.0.0'
type: string
mode:
description: 'Defines transport protocol mode: unix_udp (UDP over
Unix socket), unix_tcp (TCP over Unix socket), tcp or udp'
enum:
- unix_udp
- unix_tcp
- tcp
- udp
type: string
parser:
description: Specify an alternative parser for the message. If
Mode is set to tcp or udp then the default parser is syslog-rfc5424
otherwise syslog-rfc3164-local is used. If your syslog messages
have fractional seconds set this Parser value to syslog-rfc5424
instead.
type: string
path:
description: If Mode is set to unix_tcp or unix_udp, set the absolute
path to the Unix socket file.
type: string
port:
description: If Mode is set to tcp or udp, specify the TCP port
to listen for incoming connections.
format: int32
maximum: 65535
minimum: 1
type: integer
receiveBufferSize:
description: Specify the maximum socket receive buffer size. If
not set, the default value is OS-dependant, but generally too
low to accept thousands of syslog messages per second without
loss on udp or unix_udp sockets. Note that on Linux the value
is capped by sysctl net.core.rmem_max.
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
sourceAddressKey:
description: Specify the key where the source address will be
injected.
type: string
unixPerm:
description: 'If Mode is set to unix_tcp or unix_udp, set the
permission of the Unix socket file, default: 0644'
format: int32
type: integer
type: object
systemd:
description: Systemd defines Systemd Input configuration.
properties:
Expand Down
Loading

0 comments on commit da22f5e

Please sign in to comment.