Bird
0
0

You want to filter out logs from Kubernetes system namespaces (like kube-system and default) before sending to Elasticsearch in Fluentd. Which configuration snippet achieves this?

hard📝 Best Practice Q15 of 15
Kubernetes - Monitoring and Logging
You want to filter out logs from Kubernetes system namespaces (like kube-system and default) before sending to Elasticsearch in Fluentd. Which configuration snippet achieves this?
A<pre>filter ** { @type grep <exclude> key kubernetes.namespace_name pattern ^kube-system$ </exclude> }</pre>
B<pre>filter ** { @type record_transformer remove_keys kubernetes.namespace_name }</pre>
C<pre>filter ** { @type grep <include> key kubernetes.namespace_name pattern ^kube-system$ </include> }</pre>
D<pre>filter ** { @type grep <exclude> key kubernetes.namespace_name pattern ^(kube-system|default)$ </exclude> }</pre>
Step-by-Step Solution
Solution:
  1. Step 1: Understand filtering with Fluentd grep plugin

    The grep plugin can exclude logs matching certain patterns using blocks.
  2. Step 2: Identify namespaces to exclude

    We want to exclude system namespaces like kube-system and default, so pattern must match both.
  3. Step 3: Compare options

    filter ** {
      @type grep
      
        key kubernetes.namespace_name
        pattern ^(kube-system|default)$
      
    }
    excludes both kube-system and default namespaces correctly; others exclude only one or do wrong action.
  4. Final Answer:

    filter ** { @type grep key kubernetes.namespace_name pattern ^(kube-system|default)$ } -> Option D
  5. Quick Check:

    Exclude system namespaces with grep exclude pattern [OK]
Quick Trick: Use grep exclude with regex for system namespaces [OK]
Common Mistakes:
  • Excluding only one namespace
  • Using include instead of exclude
  • Removing keys instead of filtering logs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes