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 all commits
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
@@ -0,0 +1,30 @@
<source>
@type forward
bind 0.0.0.0
port 24224
</source>
<match **>
@id main
@type label_router
<route>
@label @a2170d34e9940ec56d328100e375c43e
<match>
namespaces default,kube-system
</match>
</route>
</match>
<label @a2170d34e9940ec56d328100e375c43e>
<filter **>
@id ClusterFluentdConfig-cluster-fluentd-config::cluster::clusterfilter::fluentd-filter-0
@type record_transformer
enable_ruby true
<record>
kubernetes_ns ${record["kubernetes"]["namespace_name"]}
</record>
</filter>
<match **>
@id ClusterFluentdConfig-cluster-fluentd-config::cluster::clusteroutput::fluentd-output-null-0
@type null
never_flush false
</match>
</label>
Loading
Loading