• Stars
    star
    580
  • Rank 77,010 (Top 2 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 6 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Operate Fluent Bit and Fluentd in the Kubernetes way - Previously known as FluentBit Operator

banner

Facilitate the management of Fluent Bit and Fluentd in Kubernetes

A+ good first follow on Twitter

Fluent Operator

Fluent Operator provides great flexibility in building a logging layer based on Fluent Bit and Fluentd.

Once installed, the Fluent Operator provides the following features:

  • Fluent Bit Management: Deploy and destroy Fluent Bit DaemonSet automatically.
  • Fluentd Management: Deploy and destroy Fluentd StatefulSet automatically.
  • Custom Configuration: Select input/filter/output plugins via labels.
  • Dynamic Reloading: Update configuration without rebooting Fluent Bit and Fluentd pods.
  • Multi-tenant log isolation: Fluentd supports multi-tenant log isolation through label_router plugin.
  • Pluggable deployment components: Either Fluent Bit or Fluentd can be deployed separately.

Table of contents

Overview

Although both Fluent Bit and Fluentd can collect, process(parse and filter) and then forward log to the final destinations, still they have strengths in different aspects.

Fluent Bit is a good choice as a logging agent because of its lightweight and efficiency, while Fluentd is more powerful to perform advanced processing on logs because of its rich plugins.

  • Fluent Bit only mode: If you just need to collect logs and send logs to the final destinations, all you need is Fluent Bit.
  • Fluent Bit + Fluentd mode: If you also need to perform some advanced processing on the logs collected or send to more sinks, then you also need Fluentd.
  • Fluentd only mode: If you need to receive logs through networks like HTTP or Syslog and then process and send the log to the final sinks, you only need Fluentd.

Fluent Operator includes CRDs and controllers for both Fluent Bit and Fluentd which allows you to config your log processing pipelines in the 3 modes mentioned above as you wish.

Fluent Bit will be deployed as a DaemonSet while Fluentd will be deployed as a StatefulSet. The whole workflow could be described as below:

Fluent-operator

Fluent Bit

The following CRDs are defined for Fluent Bit:

  • FluentBit: Defines the Fluent Bit DaemonSet and its configs. A custom Fluent Bit image kubesphere/fluent-bit is required to work with FluentBit Operator for dynamic configuration reloading.
  • ClusterFluentBitConfig: Select cluster-level input/filter/output plugins and generates the final config into a Secret.
  • FluentBitConfig: Selects namespace-level filter/output/parser and cluster-level parser plugins and generates final config into a Secret.
  • ClusterInput: Defines cluster-level input config sections.
  • Parser: Defines namespace-level parser config sections.
  • ClusterParser: Defines cluster-level parser config sections.
  • Filter: Defines namespace-level filter config sections.
  • ClusterFilter: Defines cluster-level filter config sections.
  • Output: Defines namespace-level output config sections.
  • ClusterOutput: Defines cluster-level output config sections.

Each ClusterInput, ClusterParser, ClusterFilter, ClusterOutput represents a Fluent Bit config section, which are selected by ClusterFluentBitConfig via label selectors. Fluent Operator watches those objects, constructs the final config, and finally creates a Secret to store the config which will be mounted into the Fluent Bit DaemonSet. The entire workflow looks like below:

Fluent Bit workflow

To enable Fluent Bit to pick up and use the latest config whenever the Fluent Bit config changes, a wrapper called Fluent Bit watcher is added to restart the Fluent Bit process as soon as Fluent Bit config changes are detected. This way, the Fluent Bit pod needn't be restarted to reload the new config. The Fluent Bit config is reloaded in this way because there is no reloading interface in Fluent Bit itself. Please refer to this known issue for more details.

fluentbit-operator

Fluentd

The following CRDs are defined for Fluentd:

  • Fluentd: Defines the Fluentd Statefulset and its configs. A custom Fluentd image kubesphere/fluentd is required to work with Fluentd Operator for dynamic configuration reloading.
  • FluentdConfig: Select cluster-level or namespace-level scope input/filter/output plugins and generates the final config into a Secret.
  • ClusterFluentdConfig: Select cluster-level input/filter/output plugins and generates the final config into a Secret.
  • Filter: Defines namespace-level filter config sections.
  • ClusterFilter: Defines cluster-level filter config sections.
  • Output: Defines namespace-level output config sections.
  • ClusterOutput: Defines cluster-level output config sections.

Get Started

Prerequisites

Kubernetes v1.16.13+ is necessary for running Fluent Operator.

Install

Deploy Fluent Operator with YAML

Install the latest stable version

kubectl apply -f https://raw.githubusercontent.com/fluent/fluent-operator/release-2.5/manifests/setup/setup.yaml

# You can change the namespace in manifests/setup/kustomization.yaml in corresponding release branch 
# and then use command below to install to another namespace
# kubectl kustomize manifests/setup/ | kubectl apply -f -

Install the development version

kubectl apply -f https://raw.githubusercontent.com/fluent/fluentbit-operator/master/manifests/setup/setup.yaml

# You can change the namespace in manifests/setup/kustomization.yaml 
# and then use command below to install to another namespace
# kubectl kustomize manifests/setup/ | kubectl apply -f -

Deploy Fluent Operator with Helm

Note: For the helm based install, Helm v3.2.1 or higher is needed.

The Fluent Bit section of the Fluent Operator supports different CRI docker, containerd, and CRI-O. containerd and CRI-O use the CRI Log format which is different with docker, they requires additional parser to parse JSON application logs. You should set different containerRuntime depending on your container runtime.

The default runtime is docker, you can choose other runtimes as follows.

If your container runtime is containerd or cri-o, you can set the containerRuntime parameter to containerd or crio. e.g.

helm install fluent-operator --create-namespace -n fluent charts/fluent-operator/  --set containerRuntime=containerd

Install through the online chart link:

helm install fluent-operator --create-namespace -n fluent https://github.com/fluent/fluent-operator/releases/download/< version >/fluent-operator.tgz

Please replace < version > with a actual version like v1.0.0

Fluent Operator CRDs will be installed by default when running a helm install for the chart. But if the CRD already exists, it will be skipped with a warning. So make sure you install the CRDs by yourself if you upgrade your Fluent Operator version.

By default the installation with Helm create all the CRDs (fluent-bit and fluentd ones). If you do not intent to use one of the two components, it is possible to skip its CRDs and also to not start the controllers for it in the operator. To achieve that operator.disableComponentControllers and (fluent-bit/fluentd).crdsEnable parameters can be provided:

helm install fluent-operator --create-namespace -n fluent charts/fluent-operator/  --set operator.disableComponentControllers=fluent-bit,fluent-bit.crdsEnable=false

Note: During the upgrade process, if a CRD was previously created using the create operation, an error will occur during the apply operation. Using apply here allows the CRD to be replaced and created in its entirety in a single operation.

To replace the CRDs pull the current helm chart:

wget https://github.com/fluent/fluent-operator/releases/download/<version>/fluent-operator.tgz
tar -xf fluent-operator.tgz

To update the CRDs, run the following command:

kubectl replace -f fluent-operator/crds

Fluent Operator Walkthrough

For more info on various use cases of Fluent Operator, you can refer to Fluent-Operator-Walkthrough.

Collect Kubernetes logs

This guide provisions a logging pipeline including the Fluent Bit DaemonSet and its log input/filter/output configurations to collect Kubernetes logs including container logs and kubelet logs.

logging stack

Note that you need a running Elasticsearch v5+ cluster to receive log data before start. Remember to adjust output-elasticsearch.yaml to your own es setup. Kafka and Fluentd outputs are optional and are turned off by default.

Deploy the Kubernetes logging stack with YAML

kubectl apply -f manifests/logging-stack

# You can change the namespace in manifests/logging-stack/kustomization.yaml 
# and then use command below to install to another namespace
# kubectl kustomize manifests/logging-stack/ | kubectl apply -f -

Deploy the Kubernetes logging pipeline with Helm

You can also deploy the Kubernetes logging pipeline with Helm, just need to set the Kubernetes parameter to true (default):

helm upgrade fluent-operator --create-namespace -n fluent charts/fluent-operator/  --set containerRuntime=docker

If you want to deploy fluentd, just need to set the fluentd.enable parameter to true:

helm upgrade fluent-operator --create-namespace -n fluent charts/fluent-operator/  --set containerRuntime=docker,fluentd.enable=true

Within a couple of minutes, you should observe an index available:

$ curl localhost:9200/_cat/indices
green open ks-logstash-log-2020.04.26 uwQuoO90TwyigqYRW7MDYQ 1 1  99937 0  31.2mb  31.2mb

Success!

Collect audit logs

The Linux audit framework provides a CAPP-compliant (Controlled Access Protection Profile) auditing system that reliably collects information about any security-relevant (or non-security-relevant) event on a system. Refer to manifests/logging-stack/auditd, it supports a method for collecting audit logs from the Linux audit framework.

kubectl apply -f manifests/logging-stack/auditd

# You can change the namespace in manifests/logging-stack/auditd/kustomization.yaml 
# and then use command below to install to another namespace
# kubectl kustomize manifests/logging-stack/auditd/ | kubectl apply -f -

Within a couple of minutes, you should observe an index available:

$ curl localhost:9200/_cat/indices
green open ks-logstash-log-2021.04.06 QeI-k_LoQZ2h1z23F3XiHg  5 1 404879 0 298.4mb 149.2mb

Fluentd

Fluentd acts as a log forward layer that receives logs from Fluent Bit or other Apps through the network.

For more info on various use cases of Fluent Operator Fluentd CRDs, you can refer to Fluent-Operator-Walkthrough.

Plugins

Fluent Bit

Here you can find supported Fluent Bit plugins.

Fluentd

Here you can find supported Fluentd plugins.

Best Practice

Plugin Grouping

Here you can find the plugin group information.

Monitoring

Here you can use the built-in HTTP Server in Fluent Bit.

Custom Parser

Here you can customize parser in Fluent Bit.

Misc

If you want to learn more about Fluent-Operator, please refer to the misc.

Custom Plugin

Here you can learn how to use custom plugin in FluentBit and Fluentd.

Roadmap

  • Support containerd log format
  • Add Fluentd CRDs as the log aggregation layer with group name fluentd.fluent.io
  • Add FluentBit Cluster CRDs with new group name fluentbit.fluent.io
  • Rename the entire project to Fluent Operator
  • Support more Fluentd & FluentBit plugins

Development

Requirements

  • golang v1.16+.requirement
  • kubectl v1.19.2+.
  • kubebuilder v3.1+ (the project is build with v3.1.0)
  • Access to a Kubernetes cluster v1.19.2+

Running

  1. Install CRDs: make install
  2. Run: make run

Contributing

Documentation

API Doc is generated automatically. To modify it, edit the comment above struct fields, then run go run cmd/doc-gen/main.go.

Manifests

Most files under the folder manifests/setup are automatically generated from config. Don't edit them directly, run make manifests instead, then replace these files accordingly.

Community

About the community

Fluent Operator is sponsored and open-sourced by the KubeSphere Team and maintained by the Fluent community.

This project was accepted by the Fluent community as a sub-project in 2021 and is currently a vendor-neutral and community-driven project.

Contact us

You are welcome to join us in the Fluent community to polish it together:

Videos and blogs

More Repositories

1

fluentd

Fluentd: Unified Logging Layer (project under CNCF)
Ruby
12,329
star
2

fluent-bit

Fast and Lightweight Logs and Metrics processor for Linux, BSD, OSX and Windows
C
5,812
star
3

fluentd-kubernetes-daemonset

Fluentd daemonset for Kubernetes and it Docker image
Ruby
1,210
star
4

fluentd-ui

Web UI for Fluentd
Ruby
596
star
5

fluent-bit-kubernetes-logging

Fluent Bit Kubernetes Daemonset
466
star
6

fluentd-docker-image

Docker image for Fluentd
Dockerfile
452
star
7

fluent-logger-python

A structured logger for Fluentd (Python)
Python
424
star
8

fluent-logger-golang

A structured logger for Fluentd (Golang)
Go
380
star
9

helm-charts

Helm Charts for Fluentd and Fluent Bit
Mustache
376
star
10

fluent-plugin-s3

Amazon S3 input and output plugin for Fluentd
Ruby
308
star
11

fluent-plugin-kafka

Kafka input and output plugin for Fluentd
Ruby
298
star
12

fluentd-forwarder

Fluentd Forwarder: Lightweight Data Collector in Golang
Go
283
star
13

fluent-logger-node

A structured logger for Fluentd (Node.js)
JavaScript
257
star
14

fluent-plugin-prometheus

A fluent plugin that collects metrics and exposes for Prometheus.
Ruby
253
star
15

fluent-logger-ruby

A structured logger for Fluentd (Ruby)
Ruby
251
star
16

fluent-logger-php

A structured logger for Fluentd (PHP)
PHP
216
star
17

fluent-logger-java

A structured logger for Fluentd (Java)
Java
205
star
18

sigdump

Use signal to show stacktrace of a Ruby process without restarting it
Ruby
183
star
19

fluent-bit-go

Fluent Bit Golang package to build plugins
Go
173
star
20

fluent-plugin-mongo

MongoDB input and output plugin for Fluentd
Ruby
171
star
21

fluent-plugin-rewrite-tag-filter

Fluentd Output filter plugin to rewrite tags that matches specified attribute.
Ruby
168
star
22

fluent-bit-docs

Fluent Bit - Official Documentation
Shell
119
star
23

fluent-plugin-grok-parser

Fluentd's Grok parser
Ruby
103
star
24

fluent-plugin-sql

SQL input/output plugin for Fluentd
Ruby
102
star
25

nginx-fluentd-module

Nginx module for Fluentd data collector
C
85
star
26

fluent-bit-docker-image

Docker image for Fluent Bit
Shell
67
star
27

fluent-plugin-webhdfs

Hadoop WebHDFS output plugin for Fluentd
Ruby
59
star
28

fluent-plugin-opensearch

OpenSearch Plugin for Fluentd
Ruby
49
star
29

fluentd-docs

This repository is deprecated. Go to fluentd-docs-gitbook repository.
Ruby
49
star
30

fluentd-benchmark

Benchmark collection of fluentd use cases
Shell
47
star
31

fluent-logger-scala

A structured logger implementation in Scala.
Shell
45
star
32

NLog.Targets.Fluentd

C#
44
star
33

fluent-logger-perl

A structured logger for Fluentd (Perl)
Perl
43
star
34

fluent-plugin-multiprocess

Multiprocess agent plugin for Fluentd
Ruby
42
star
35

fluentd-docs-gitbook

Fluentd documentation project in Gitbook format
JavaScript
41
star
36

fluent-plugin-splunk

Fluentd Plugin for Splunk
Ruby
38
star
37

fluent-plugin-windows-eventlog

Fluentd plugin to collect windows event logs
Ruby
33
star
38

fluent-plugin-parser-cri

CRI log parser for Fluentd
Ruby
32
star
39

fluent-bit-perf

Fluent Bit Performance Tools
C
31
star
40

fluent-plugin-flume

Flume input and output plugin for Fluentd
Ruby
23
star
41

kafka-connect-fluentd

Kafka Connect for Fluentd
Java
23
star
42

chunkio

Simple library to manage chunks of data in memory and file system
C
21
star
43

fluent-package-builder

td-agent (Fluentd) Building and Packaging System
Shell
21
star
44

fluent-plugin-scribe

Scribe input/output plugin for Fluentd data collector
Ruby
20
star
45

fluent-plugins

18
star
46

cmetrics

A standalone library to create and manipulate metrics in C
C
15
star
47

website

http://fluentd.org/
CSS
14
star
48

fluent-plugin-sanitizer

Ruby
14
star
49

fluent-bit-plugin

Fluent Bit Dynamic Plugin Development
C
13
star
50

fluent-bit-packaging

Fluent Bit Linux Packaging environment using Docker
Dockerfile
12
star
51

fluent-logger-forward-node

A fluent forward protocol implementation for Node.js
TypeScript
11
star
52

fluentd-website

For fluentd.org
CSS
10
star
53

fluent-logger-erlang

A structured logger for Fluentd (Erlang)
Erlang
10
star
54

fluent-bit-ci

CI/CD for Fluent-bit
Shell
8
star
55

fluent-plugin-msgpack-rpc

MessagePack-RPC input plugin for Fluentd data collector
Ruby
8
star
56

fluent-logger-ocaml

A structured logger for Fluentd (OCaml)
OCaml
7
star
57

fluent-plugin-hoop

Hoop (HDFS over HTTP) Plugin for Fluentd data collector
Ruby
6
star
58

data-collection

Data Collection with Fluentd
6
star
59

fluent-logger-d

A structured logger for Fluentd (D)
JavaScript
6
star
60

diagtool

Bringing productivity of trouble shooting to the next level by automating collection of Fluentd configurations, settings and OS parameters as well as masking sensitive information in logs and configurations.
Ruby
5
star
61

fluent-bit-tutorials

Fluent Bit Tutorials, custom articles to get started
5
star
62

m3-workshop-fluentcon

Shell
4
star
63

fluentbit-website-v3

CSS
4
star
64

fluent.github.com

website
JavaScript
4
star
65

fluentd-aggregator-docker-image

A Fluentd container image to be used for log aggregation and based on the official Fluentd Docker image.
Dockerfile
4
star
66

fluent-bit-observability-demo

JavaScript
3
star
67

fluent-bit-docs-stream-processing

Fluent Bit Stream Processing Guide
3
star
68

onigmo

Onigmo library with security and stable patches on top by Fluent maintainers
C
3
star
69

fluent-bit-website

Fluent Bit Website (work in process)
HTML
3
star
70

fluent-plugin-sd-dns

DNS based service discovery plugin for Fluentd
Ruby
2
star
71

fluent-bit-test

Testing infrastructure for Fluent Bit
2
star
72

fluent-bit-labs

Fluent Bit Dev Labs
2
star
73

fluent-bit-website-old

Fluent Bit website
CSS
2
star
74

fluentbit-website-v2

Fluent Bit Website v2
CSS
2
star
75

fluent-plugin-buffer-chunkio

Ruby
2
star
76

fluent-bit-chatops-demo

Demo of using Fluent Bit for ChatOps - created for Cloud Native Rejekts EU 2024 talk
Java
2
star
77

fluent-bit-infra

Automation related to fluent-bit infrastructure
HCL
2
star
78

fluent-plugin-parser-winevt_xml

Fluentd Parser plugin to parse XML rendered windows event log.
Ruby
1
star
79

cfl

Tiny library for data structures management, call it c:\ floppy
C
1
star
80

fluentd-docs-kubernetes

Fluentd DaemonSet Documentation for Kubernetes
1
star
81

fluent-bit-sandbox

A repository to covering the setup and configuration of the Fluent Bit Sandbox.
Shell
1
star
82

fluent-plugin-prometheus_pushgateway

Ruby
1
star
83

fluentd-website-hugo

SCSS
1
star
84

ctraces

Library to create and manipulate traces in C
C
1
star