Skip to content

Commit 5486405

Browse files
authored
Merge pull request #1578 from cw-Guo/feat/fluentd-null-plugin
feat(fluentd): add null output plugin
2 parents 8d3a44d + d6ed446 commit 5486405

File tree

14 files changed

+183
-110
lines changed

14 files changed

+183
-110
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package output
2+
3+
// Null defines the parameters for out_null output plugin
4+
type Null struct {
5+
// NeverFlush for testing to simulate the output plugin that never succeeds to flush.
6+
NeverFlush *bool `json:"neverFlush,omitempty"`
7+
}

apis/fluentd/v1alpha1/plugins/output/types.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ type Output struct {
5454
Datadog *Datadog `json:"datadog,omitempty"`
5555
// copy plugin
5656
Copy *Copy `json:"copy,omitempty"`
57+
// null plugin
58+
Null *Null `json:"nullPlugin,omitempty"`
5759
}
5860

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

182+
if o.Null != nil {
183+
ps.InsertType(string(params.NullOutputType))
184+
return o.nullPlugin(ps, loader), nil
185+
}
186+
180187
return o.customOutput(ps, loader), nil
181188

182189
}
@@ -1074,4 +1081,11 @@ func (o *Output) copyPlugin(parent *params.PluginStore, sl plugins.SecretLoader)
10741081
return parent
10751082
}
10761083

1084+
func (o *Output) nullPlugin(parent *params.PluginStore, sl plugins.SecretLoader) *params.PluginStore {
1085+
if o.Null.NeverFlush != nil {
1086+
parent.InsertPairs("never_flush", fmt.Sprint(*o.Null.NeverFlush))
1087+
}
1088+
return parent
1089+
}
1090+
10771091
var _ plugins.Plugin = &Output{}

apis/fluentd/v1alpha1/plugins/params/const.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const (
7373
CloudWatchOutputType OutputType = "cloudwatch_logs"
7474
DatadogOutputType OutputType = "datadog"
7575
CopyOutputType OutputType = "copy"
76+
NullOutputType OutputType = "null"
7677
)
7778

7879
var (
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<source>
2+
@type forward
3+
bind 0.0.0.0
4+
port 24224
5+
</source>
6+
<match **>
7+
@id main
8+
@type label_router
9+
<route>
10+
@label @a2170d34e9940ec56d328100e375c43e
11+
<match>
12+
namespaces default,kube-system
13+
</match>
14+
</route>
15+
</match>
16+
<label @a2170d34e9940ec56d328100e375c43e>
17+
<filter **>
18+
@id ClusterFluentdConfig-cluster-fluentd-config::cluster::clusterfilter::fluentd-filter-0
19+
@type record_transformer
20+
enable_ruby true
21+
<record>
22+
kubernetes_ns ${record["kubernetes"]["namespace_name"]}
23+
</record>
24+
</filter>
25+
<match **>
26+
@id ClusterFluentdConfig-cluster-fluentd-config::cluster::clusteroutput::fluentd-output-null-0
27+
@type null
28+
never_flush false
29+
</match>
30+
</label>

0 commit comments

Comments
 (0)