Skip to content

feat(fluentd): add null output plugin #1578

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 4 commits into from
May 6, 2025
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
7 changes: 7 additions & 0 deletions apis/fluentd/v1alpha1/plugins/output/null.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package output

// Null defines the parameters for out_null output plugin
type Null struct {
// NeverFlush for testing to simulate the output plugin that never succeeds to flush.
NeverFlush *bool `json:"neverFlush,omitempty"`
}
14 changes: 14 additions & 0 deletions apis/fluentd/v1alpha1/plugins/output/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ type Output struct {
Datadog *Datadog `json:"datadog,omitempty"`
// copy plugin
Copy *Copy `json:"copy,omitempty"`
// null plugin
Null *Null `json:"nullPlugin,omitempty"`
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I change the name of this pulgin from null to nullPlugin, it was due to that null is a keywoard in yaml, so it will be converted to "null" as below:

apiVersion: fluentd.fluent.io/v1alpha1
kind: ClusterOutput
metadata:
  name: fluentd-only-null
  namespace: fluent
  labels:
    output.fluentd.fluent.io/mode: "fluentd-only"
spec: 
  outputs: 
  - "null":
      neverFlush: false

}

// DeepCopyInto implements the DeepCopyInto interface.
Expand Down Expand Up @@ -177,6 +179,11 @@ func (o *Output) Params(loader plugins.SecretLoader) (*params.PluginStore, error
return o.copyPlugin(ps, loader), nil
}

if o.Null != nil {
ps.InsertType(string(params.NullOutputType))
return o.nullPlugin(ps, loader), nil
}

return o.customOutput(ps, loader), nil

}
Expand Down Expand Up @@ -1074,4 +1081,11 @@ func (o *Output) copyPlugin(parent *params.PluginStore, sl plugins.SecretLoader)
return parent
}

func (o *Output) nullPlugin(parent *params.PluginStore, sl plugins.SecretLoader) *params.PluginStore {
if o.Null.NeverFlush != nil {
parent.InsertPairs("never_flush", fmt.Sprint(*o.Null.NeverFlush))
}
return parent
}

var _ plugins.Plugin = &Output{}
1 change: 1 addition & 0 deletions apis/fluentd/v1alpha1/plugins/params/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const (
CloudWatchOutputType OutputType = "cloudwatch_logs"
DatadogOutputType OutputType = "datadog"
CopyOutputType OutputType = "copy"
NullOutputType OutputType = "null"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2226,6 +2226,14 @@ spec:
required:
- url
type: object
nullPlugin:
description: null plugin
properties:
neverFlush:
description: NeverFlush for testing to simulate the output
plugin that never succeeds to flush.
type: boolean
type: object
opensearch:
description: out_opensearch plugin
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2226,6 +2226,14 @@ spec:
required:
- url
type: object
nullPlugin:
description: null plugin
properties:
neverFlush:
description: NeverFlush for testing to simulate the output
plugin that never succeeds to flush.
type: boolean
type: object
opensearch:
description: out_opensearch plugin
properties:
Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/fluentd.fluent.io_clusteroutputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2226,6 +2226,14 @@ spec:
required:
- url
type: object
nullPlugin:
description: null plugin
properties:
neverFlush:
description: NeverFlush for testing to simulate the output
plugin that never succeeds to flush.
type: boolean
type: object
opensearch:
description: out_opensearch plugin
properties:
Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/fluentd.fluent.io_outputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2226,6 +2226,14 @@ spec:
required:
- url
type: object
nullPlugin:
description: null plugin
properties:
neverFlush:
description: NeverFlush for testing to simulate the output
plugin that never succeeds to flush.
type: boolean
type: object
opensearch:
description: out_opensearch plugin
properties:
Expand Down
8 changes: 8 additions & 0 deletions docs/plugins/fluentd/output/null.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Null

Null defines the parameters for out_null output plugin


| Field | Description | Scheme |
| ----- | ----------- | ------ |
| neverFlush | NeverFlush for testing to simulate the output plugin that never succeeds to flush. | *bool |
1 change: 1 addition & 0 deletions docs/plugins/fluentd/output/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ Output defines all available output plugins and their parameters
| cloudWatch | out_cloudwatch plugin | *[CloudWatch](#cloudwatch) |
| datadog | datadog plugin | *[Datadog](#datadog) |
| copy | copy plugin | *[Copy](#copy) |
| nullPlugin | null plugin | *[Null](#null) |
16 changes: 16 additions & 0 deletions manifests/setup/fluent-operator-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10723,6 +10723,14 @@ spec:
required:
- url
type: object
nullPlugin:
description: null plugin
properties:
neverFlush:
description: NeverFlush for testing to simulate the output
plugin that never succeeds to flush.
type: boolean
type: object
opensearch:
description: out_opensearch plugin
properties:
Expand Down Expand Up @@ -39580,6 +39588,14 @@ spec:
required:
- url
type: object
nullPlugin:
description: null plugin
properties:
neverFlush:
description: NeverFlush for testing to simulate the output
plugin that never succeeds to flush.
type: boolean
type: object
opensearch:
description: out_opensearch plugin
properties:
Expand Down
16 changes: 16 additions & 0 deletions manifests/setup/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10723,6 +10723,14 @@ spec:
required:
- url
type: object
nullPlugin:
description: null plugin
properties:
neverFlush:
description: NeverFlush for testing to simulate the output
plugin that never succeeds to flush.
type: boolean
type: object
opensearch:
description: out_opensearch plugin
properties:
Expand Down Expand Up @@ -39580,6 +39588,14 @@ spec:
required:
- url
type: object
nullPlugin:
description: null plugin
properties:
neverFlush:
description: NeverFlush for testing to simulate the output
plugin that never succeeds to flush.
type: boolean
type: object
opensearch:
description: out_opensearch plugin
properties:
Expand Down
Loading