Use a label to determine whether to forward logs or not with Fluentd daemonset in K8s

template:
metadata:
labels:
app: myapp
console_log_forward: noforward
<match kubernetes.**>
@type rewrite_tag_filter
<rule>
key $.kubernetes.labels.console_log_forward
pattern /^noforward$/
tag clear
</rule>
# If there's other rewrite rules, add them here
</match>
<match clear>
@type null
</match>
  • Pods with console_log_forward: noforward label => pod logs will NOT be forward by fluentd.
  • Pods without console_log_forward label => pod logs will not enter the above <match>, logs with continually be handled by the rest of the fluentd.config
  • Pods with console_log_forward label but with a value other than “noforward” => pod logs will not enter the above <match>, log with continually be handled by the rest of your fluentd.config.

--

--

--

Data Engineer from Taiwan, recently working on EFK and Kubernetes projects.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Using Bootstrap to create a student directory

Spring Initializr

Elegant Dashboards for Python ML Apps using Taipy GUI

Plasma.Finance Launches a Referral Program

The Escape Button is a Feature

Lambda Expressions in Java 8 (Part 4)

Top Web 3.0 Developed Apps You Must Know About

I once took a technical recruiting job because it promised that if I worked hard

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jasmine H

Jasmine H

Data Engineer from Taiwan, recently working on EFK and Kubernetes projects.

More from Medium

Build and deploy PHP Guestbook application on Local Kubernetes with Skaffold

Kubernetes: Ordered cleanup with OwnerReference

[Solution] How to Deploy Argo CD Dashboard over Nginx Ingress-Controller

Kubernetes — Debugging NetworkPolicy (Part 3)