The Kubernetes Filter allows to enrich your log files with Kubernetes metadata.
When Fluent Bit is deployed in Kubernetes as a DaemonSet and configured to read the log files from the containers (using tail plugin), this filter aims to perform the following operations:
Analyze the Tag and extract the following metadata:
Query Kubernetes API Server to obtain extra metadata for the POD in question:
The data is cached locally in memory and appended to each record.
The plugin supports the following configuration parameters:
Set the buffer size for HTTP client when reading responses from Kubernetes API server. The value must be according to the Unit Size specification.
API Server end-point
CA certificate file
Absolute path to scan for certificate files
When enabled, it checks if the
Debug level between 0 (nothing) and 4 (every detail).
When enabled, turns on certificate validation when connecting to the Kubernetes API server.
When enabled, the filter reads logs coming in Journald format.
Set an alternative Parser to process record Tag and extract pod_name, namespace_name, container_name and docker_id. The parser must be registered in a parsers file (refer to parser filter-kube-test as an example).
Allow Kubernetes Pods to suggest a pre-defined Parser (read more about it in Kubernetes Annotations section)
Allow Kubernetes Pods to exclude their logs from the log processor (read more about it in Kubernetes Annotations section).
If set, Kubernetes meta-data can be cached/pre-loaded from files in JSON format in this directory, named as namespace-pod.meta
If set, use dummy-meta data (for test/dev purposes)
A flexible feature of Fluent Bit Kubernetes filter is that allow Kubernetes Pods to suggest certain behaviors for the log processor pipeline when processing the records. At the moment it support:
Suggest a pre-defined parser
Request to exclude logs
The following annotations are available:
Suggest a pre-defined parser. The parser must be registered already by Fluent Bit. This option will only be processed if Fluent Bit configuration (Kubernetes Filter) have enabled the option K8S-Logging.Parser. If present, the stream (stdout or stderr) will restrict that specific stream. If present, the container can override a specific container in a Pod.
Request to Fluent Bit to exclude or not the logs generated by the Pod. This option will only be processed if Fluent Bit configuration (Kubernetes Filter) have enabled the option K8S-Logging.Exclude.
The following Pod definition runs a Pod that emits Apache logs to the standard output, in the Annotations it suggest that the data should be processed using the pre-defined parser called apache:
apiVersion: v1kind: Podmetadata:name: apache-logslabels:app: apache-logsannotations:fluentbit.io/parser: apachespec:containers:- name: apacheimage: edsiper/apache_logs
There are certain situations where the user would like to request that the log processor simply skip the logs from the Pod in question:
apiVersion: v1kind: Podmetadata:name: apache-logslabels:app: apache-logsannotations:fluentbit.io/exclude: "true"spec:containers:- name: apacheimage: edsiper/apache_logs
Note that the annotation value is boolean which can take a true or false and must be quoted.