From b0586a9ba1d76cf412173bd427b0ff0b1766faa7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9Csjliu1=E2=80=9D?= <“sj_liu123@163.com”>
Date: Mon, 11 Sep 2023 12:02:53 +0800
Subject: [PATCH] [summerospp]add fluentbit collectd plugin
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: “sjliu1” <“sj_liu123@163.com”>
---
apis/fluentbit/v1alpha2/clusterinput_types.go | 2 +
.../v1alpha2/plugins/input/collectd.go | 42 +++++++++++++++++++
.../plugins/input/zz_generated.deepcopy.go | 20 +++++++++
.../v1alpha2/zz_generated.deepcopy.go | 5 +++
.../fluentbit.fluent.io_clusterinputs.yaml | 16 +++++++
.../fluentbit.fluent.io_clusterinputs.yaml | 16 +++++++
docs/fluentbit.md | 1 +
docs/plugins/fluentbit/input/collectd.md | 10 +++++
manifests/setup/fluent-operator-crd.yaml | 16 +++++++
manifests/setup/setup.yaml | 16 +++++++
10 files changed, 144 insertions(+)
create mode 100644 apis/fluentbit/v1alpha2/plugins/input/collectd.go
create mode 100644 docs/plugins/fluentbit/input/collectd.md
diff --git a/apis/fluentbit/v1alpha2/clusterinput_types.go b/apis/fluentbit/v1alpha2/clusterinput_types.go
index 7c3b3864b..266e009ac 100644
--- a/apis/fluentbit/v1alpha2/clusterinput_types.go
+++ b/apis/fluentbit/v1alpha2/clusterinput_types.go
@@ -61,6 +61,8 @@ type InputSpec struct {
HTTP *input.HTTP `json:"http,omitempty"`
// MQTT defines the MQTT input plugin configuration
MQTT *input.MQTT `json:"mqtt,omitempty"`
+ // Collectd defines the Collectd input plugin configuration
+ Collectd *input.Collectd `json:"collectd,omitempty"`
}
// +kubebuilder:object:root=true
diff --git a/apis/fluentbit/v1alpha2/plugins/input/collectd.go b/apis/fluentbit/v1alpha2/plugins/input/collectd.go
new file mode 100644
index 000000000..505a34987
--- /dev/null
+++ b/apis/fluentbit/v1alpha2/plugins/input/collectd.go
@@ -0,0 +1,42 @@
+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 Collectd input plugin allows you to receive datagrams from collectd service.
+// **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/collectd**
+type Collectd struct {
+ // Set the address to listen to, default: 0.0.0.0
+ Listen string `json:"listen,omitempty"`
+ // Set the port to listen to, default: 25826
+ // +kubebuilder:validation:Minimum:=1
+ // +kubebuilder:validation:Maximum:=65535
+ Port *int32 `json:"port,omitempty"`
+ // Set the data specification file,default: /usr/share/collectd/types.db
+ TypesDB string `json:"typesDB,omitempty"`
+}
+
+func (_ *Collectd) Name() string {
+ return "collectd"
+}
+
+// implement Section() method
+func (c *Collectd) Params(_ plugins.SecretLoader) (*params.KVs, error) {
+ kvs := params.NewKVs()
+ if c.Listen != "" {
+ kvs.Insert("Listen", c.Listen)
+ }
+ if c.Port != nil {
+ kvs.Insert("Port", fmt.Sprint(*c.Port))
+ }
+ if c.TypesDB != "" {
+ kvs.Insert("TypesDB", c.TypesDB)
+ }
+ return kvs, nil
+}
diff --git a/apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go b/apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go
index 2ccb6983d..d3ab99473 100644
--- a/apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go
+++ b/apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go
@@ -25,6 +25,26 @@ import (
"github.com/fluent/fluent-operator/v2/apis/fluentbit/v1alpha2/plugins"
)
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *Collectd) DeepCopyInto(out *Collectd) {
+ *out = *in
+ if in.Port != nil {
+ in, out := &in.Port, &out.Port
+ *out = new(int32)
+ **out = **in
+ }
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Collectd.
+func (in *Collectd) DeepCopy() *Collectd {
+ if in == nil {
+ return nil
+ }
+ out := new(Collectd)
+ in.DeepCopyInto(out)
+ return out
+}
+
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Dummy) DeepCopyInto(out *Dummy) {
*out = *in
diff --git a/apis/fluentbit/v1alpha2/zz_generated.deepcopy.go b/apis/fluentbit/v1alpha2/zz_generated.deepcopy.go
index ed49f9665..43cc5623e 100644
--- a/apis/fluentbit/v1alpha2/zz_generated.deepcopy.go
+++ b/apis/fluentbit/v1alpha2/zz_generated.deepcopy.go
@@ -1093,6 +1093,11 @@ func (in *InputSpec) DeepCopyInto(out *InputSpec) {
*out = new(input.MQTT)
(*in).DeepCopyInto(*out)
}
+ if in.Collectd != nil {
+ in, out := &in.Collectd, &out.Collectd
+ *out = new(input.Collectd)
+ (*in).DeepCopyInto(*out)
+ }
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InputSpec.
diff --git a/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterinputs.yaml b/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterinputs.yaml
index 36e29de9b..f947812b7 100644
--- a/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterinputs.yaml
+++ b/charts/fluent-operator/charts/fluent-bit-crds/crds/fluentbit.fluent.io_clusterinputs.yaml
@@ -41,6 +41,22 @@ spec:
description: A user friendly alias name for this input plugin. Used
in metrics for distinction of each configured input.
type: string
+ collectd:
+ description: Collectd defines the Collectd input plugin configuration
+ properties:
+ listen:
+ description: 'Set the address to listen to, default: 0.0.0.0'
+ type: string
+ port:
+ description: 'Set the port to listen to, default: 25826'
+ format: int32
+ maximum: 65535
+ minimum: 1
+ type: integer
+ typesDB:
+ description: 'Set the data specification file,default: /usr/share/collectd/types.db'
+ type: string
+ type: object
customPlugin:
description: CustomPlugin defines Custom Input configuration.
properties:
diff --git a/config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml b/config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml
index 36e29de9b..f947812b7 100644
--- a/config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml
+++ b/config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml
@@ -41,6 +41,22 @@ spec:
description: A user friendly alias name for this input plugin. Used
in metrics for distinction of each configured input.
type: string
+ collectd:
+ description: Collectd defines the Collectd input plugin configuration
+ properties:
+ listen:
+ description: 'Set the address to listen to, default: 0.0.0.0'
+ type: string
+ port:
+ description: 'Set the port to listen to, default: 25826'
+ format: int32
+ maximum: 65535
+ minimum: 1
+ type: integer
+ typesDB:
+ description: 'Set the data specification file,default: /usr/share/collectd/types.db'
+ type: string
+ type: object
customPlugin:
description: CustomPlugin defines Custom Input configuration.
properties:
diff --git a/docs/fluentbit.md b/docs/fluentbit.md
index 8d5d4f34a..eafd4ff09 100644
--- a/docs/fluentbit.md
+++ b/docs/fluentbit.md
@@ -422,6 +422,7 @@ InputSpec defines the desired state of ClusterInput
| openTelemetry | OpenTelemetry defines the OpenTelemetry input plugin configuration | *[input.OpenTelemetry](plugins/input/opentelemetry.md) |
| http | HTTP defines the HTTP input plugin configuration | *[input.HTTP](plugins/input/http.md) |
| mqtt | MQTT defines the MQTT input plugin configuration | *[input.MQTT](plugins/input/mqtt.md) |
+| collectd | Collectd defines the Collectd input plugin configuration | *[input.Collectd](plugins/input/collectd.md) |
[Back to TOC](#table-of-contents)
# NamespacedFluentBitCfgSpec
diff --git a/docs/plugins/fluentbit/input/collectd.md b/docs/plugins/fluentbit/input/collectd.md
new file mode 100644
index 000000000..d9947f292
--- /dev/null
+++ b/docs/plugins/fluentbit/input/collectd.md
@@ -0,0 +1,10 @@
+# Collectd
+
+The Collectd input plugin allows you to receive datagrams from collectd service.
**For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/collectd**
+
+
+| Field | Description | Scheme |
+| ----- | ----------- | ------ |
+| listen | Set the address to listen to, default: 0.0.0.0 | string |
+| port | Set the port to listen to, default: 25826 | *int32 |
+| typesDB | Set the data specification file,default: /usr/share/collectd/types.db | string |
diff --git a/manifests/setup/fluent-operator-crd.yaml b/manifests/setup/fluent-operator-crd.yaml
index 12a0bd113..dd1ed3760 100644
--- a/manifests/setup/fluent-operator-crd.yaml
+++ b/manifests/setup/fluent-operator-crd.yaml
@@ -1790,6 +1790,22 @@ spec:
description: A user friendly alias name for this input plugin. Used
in metrics for distinction of each configured input.
type: string
+ collectd:
+ description: Collectd defines the Collectd input plugin configuration
+ properties:
+ listen:
+ description: 'Set the address to listen to, default: 0.0.0.0'
+ type: string
+ port:
+ description: 'Set the port to listen to, default: 25826'
+ format: int32
+ maximum: 65535
+ minimum: 1
+ type: integer
+ typesDB:
+ description: 'Set the data specification file,default: /usr/share/collectd/types.db'
+ type: string
+ type: object
customPlugin:
description: CustomPlugin defines Custom Input configuration.
properties:
diff --git a/manifests/setup/setup.yaml b/manifests/setup/setup.yaml
index 44e35aeb2..940b1bd44 100644
--- a/manifests/setup/setup.yaml
+++ b/manifests/setup/setup.yaml
@@ -1790,6 +1790,22 @@ spec:
description: A user friendly alias name for this input plugin. Used
in metrics for distinction of each configured input.
type: string
+ collectd:
+ description: Collectd defines the Collectd input plugin configuration
+ properties:
+ listen:
+ description: 'Set the address to listen to, default: 0.0.0.0'
+ type: string
+ port:
+ description: 'Set the port to listen to, default: 25826'
+ format: int32
+ maximum: 65535
+ minimum: 1
+ type: integer
+ typesDB:
+ description: 'Set the data specification file,default: /usr/share/collectd/types.db'
+ type: string
+ type: object
customPlugin:
description: CustomPlugin defines Custom Input configuration.
properties: