Configuring Fluent Bit for Yandex Cloud Logging
The Fluent Bit log processor lets you transfer the Managed Service for Kubernetes cluster logs to Yandex Cloud Logging. The Fluent Bit plugin for Yandex Cloud Logging module is used to transfer logs.
To set up transfer of logs:
Before you begin
-
If you don't have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the
--folder-name
or--folder-id
parameter. -
Create a service account, which is required for Fluent Bit.
-
Assign it the role
logging.writer
. -
Create an authorized key and save it to a file named
key.json
:yc iam key create \ --service-account-name <name of service account for Fluent Bit> \ --output key.json
-
-
Create a Kubernetes cluster and a node group in any suitable configuration with Kubernetes version 1.21 or higher.
-
Install kubectl and configure it to work with the created cluster.
Install and configure Fluent Bit
- Install Fluent Bit by following the instructions.
- Check transmission of Kubernetes cluster logs to Cloud Logging.
-
Create the objects necessary for Fluent Bit to run:
-
For clusters with Kubernetes versions 1.21 and lower:
kubectl create namespace logging && \ kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/fluent-bit-service-account.yaml && \ kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/fluent-bit-role.yaml && \ kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/fluent-bit-role-binding.yaml
-
For clusters with Kubernetes versions 1.22 and higher:
kubectl create namespace logging && \ kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/fluent-bit-service-account.yaml && \ kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/fluent-bit-role-1.22.yaml && \ kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/fluent-bit-role-binding-1.22.yaml
-
-
Create a secret including the key of the service account:
kubectl create secret generic secret-key-json \ --from-file=key.json \ --namespace logging
-
Download the
config.yaml
configuration file:wget https://raw.githubusercontent.com/knpsh/yc-logging-fluent-bit-example/main/config.yaml
-
Enter the log output parameters in the
data.output-elasticsearch.conf
section inconfig.yaml
:... output-elasticsearch.conf: | [OUTPUT] Name yc-logging Match * group_id <log group ID> resource_id <optional: cluster ID Kubernetes> message_key log authorization iam-key-file:/etc/secret/key.json ...
You can request the log group ID with a list of log groups in the folder.
If necessary, specify additional settings for the Fluent Bit.
-
Create Fluent Bit objects:
kubectl apply -f config.yaml
Result:
configmap/fluent-bit-config created daemonset.apps/fluent-bit created
-
Make sure the Fluent Bit status changed to
Running
:kubectl get pods -n logging
-
Check transmission of Kubernetes cluster logs to Cloud Logging.
Delete the resources you created
If you no longer need these resources, delete them:
- Delete the Managed Service for Kubernetes cluster.
- If you reserved a public static IP address for the cluster, delete it.
- Delete the log group.