Skip to content

[summerospp]add fluentbit mqtt plugin #911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apis/fluentbit/v1alpha2/clusterinput_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ type InputSpec struct {
OpenTelemetry *input.OpenTelemetry `json:"openTelemetry,omitempty"`
// HTTP defines forward input plugin configuration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// HTTP defines forward input plugin configuration
// HTTP defines the HTTP input plugin

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// OpenTelemetry defines the OpenTelemetry input plugin

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks!

HTTP *input.HTTP `json:"http,omitempty"`
// MQTT defines forward input plugin configuration
Copy link
Member

@benjaminhuo benjaminhuo Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// MQTT defines forward input plugin configuration
// MQTT defines the MQTT input plugin

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks!

MQTT *input.MQTT `json:"mqtt,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
38 changes: 38 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/input/mqtt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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 MQTT input plugin, allows to retrieve messages/data from MQTT control packets over a TCP connection. <br />
// The incoming data to receive must be a JSON map. <br />
// **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/mqtt**
type MQTT struct {
// Listener network interface, default: 0.0.0.0
Listen string `json:"listen,omitempty"`
// TCP port where listening for connections, default: 1883
// +kubebuilder:validation:Minimum:=1
// +kubebuilder:validation:Maximum:=65535
Port *int32 `json:"port,omitempty"`
}

func (_ *MQTT) Name() string {
return "mqtt"
}

// implement Section() method
func (m *MQTT) Params(_ plugins.SecretLoader) (*params.KVs, error) {
kvs := params.NewKVs()
if m.Listen != "" {
kvs.Insert("Listen", m.Listen)
}
if m.Port != nil {
kvs.Insert("Port", fmt.Sprint(*m.Port))
}
return kvs, nil
}
20 changes: 20 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 @@ -236,6 +236,20 @@ spec:
- debug
- trace
type: string
mqtt:
description: MQTT defines forward input plugin configuration
properties:
listen:
description: 'Listener network interface, default: 0.0.0.0'
type: string
port:
description: 'TCP port where listening for connections, default:
1883'
format: int32
maximum: 65535
minimum: 1
type: integer
type: object
nodeExporterMetrics:
description: NodeExporterMetrics defines Node Exporter Metrics Input
configuration.
Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,20 @@ spec:
- debug
- trace
type: string
mqtt:
description: MQTT defines forward input plugin configuration
properties:
listen:
description: 'Listener network interface, default: 0.0.0.0'
type: string
port:
description: 'TCP port where listening for connections, default:
1883'
format: int32
maximum: 65535
minimum: 1
type: integer
type: object
nodeExporterMetrics:
description: NodeExporterMetrics defines Node Exporter Metrics Input
configuration.
Expand Down
3 changes: 2 additions & 1 deletion docs/fluentbit.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,8 @@ InputSpec defines the desired state of ClusterInput
| customPlugin | CustomPlugin defines Custom Input configuration. | *custom.CustomPlugin |
| forward | Forward defines forward input plugin configuration | *[input.Forward](plugins/input/forward.md) |
| openTelemetry | OpenTelemetry defines forward input plugin configuration | *[input.OpenTelemetry](plugins/input/opentelemetry.md) |
| http | HTTP defines forward input plugin configuration | *[input.OpenTelemetry](plugins/input/opentelemetry.md) |
| http | HTTP defines forward input plugin configuration | *[input.HTTP](plugins/input/http.md) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs not updated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done it, thanks!

| mqtt | MQTT defines forward input plugin configuration | *[input.MQTT](plugins/input/mqtt.md) |

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

The MQTT input plugin, allows to retrieve messages/data from MQTT control packets over a TCP connection. <br /> The incoming data to receive must be a JSON map. <br /> **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/mqtt**


| Field | Description | Scheme |
| ----- | ----------- | ------ |
| listen | Listener network interface, default: 0.0.0.0 | string |
| port | TCP port where listening for connections, default: 1883 | *int32 |
14 changes: 14 additions & 0 deletions manifests/setup/fluent-operator-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1985,6 +1985,20 @@ spec:
- debug
- trace
type: string
mqtt:
description: MQTT defines forward input plugin configuration
properties:
listen:
description: 'Listener network interface, default: 0.0.0.0'
type: string
port:
description: 'TCP port where listening for connections, default:
1883'
format: int32
maximum: 65535
minimum: 1
type: integer
type: object
nodeExporterMetrics:
description: NodeExporterMetrics defines Node Exporter Metrics Input
configuration.
Expand Down
14 changes: 14 additions & 0 deletions manifests/setup/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1985,6 +1985,20 @@ spec:
- debug
- trace
type: string
mqtt:
description: MQTT defines forward input plugin configuration
properties:
listen:
description: 'Listener network interface, default: 0.0.0.0'
type: string
port:
description: 'TCP port where listening for connections, default:
1883'
format: int32
maximum: 65535
minimum: 1
type: integer
type: object
nodeExporterMetrics:
description: NodeExporterMetrics defines Node Exporter Metrics Input
configuration.
Expand Down