Fluent BitをCentOS7でビルドする

Fluent Bit: Official Manualの手順だけではなかなかうまくいかなかったので、ビルド手順をまとめます。

https://docs.fluentbit.io/manual/installation/sources/build-and-install

コンテナ上で作業をします。

podman run -itd --name centos4 \
        -v "$PWD"/data/:/opt/ \
        quay.io/centos/centos:centos7.9.2009

fluent-bitのビルドに必要なものをyumでインストールします。

次に、fluent-bitのソースをgit cloneし、ビルドします。

yum update -y
yum -y install epel-release
yum -y install git cmake3 zlib-devel libyaml-devel openssl-devel
yum -y groupinstall "Development Tools"


git clone https://github.com/fluent/fluent-bit
cd ./fluent-bit/build/
cmake3 ../
make -j 4
make install

ビルドとインストールに成功すると、下記のようにバージョンが確認できます。

# fluent-bit --version
Fluent Bit v2.1.0
Git commit: a6f2006327709e55722034932765e69eeaed78af

試しにcpuの情報を表示してみます。

# fluent-bit -i cpu -o stdout
Fluent Bit v2.1.0
* Copyright (C) 2015-2022 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2023/03/28 14:58:32] [ info] [fluent bit] version=2.1.0, commit=a6f2006327, pid=23355
[2023/03/28 14:58:32] [ info] [storage] ver=1.4.0, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/03/28 14:58:32] [ info] [cmetrics] version=0.5.9
[2023/03/28 14:58:32] [ info] [ctraces ] version=0.3.0
[2023/03/28 14:58:32] [ info] [input:cpu:cpu.0] initializing
[2023/03/28 14:58:32] [ info] [input:cpu:cpu.0] storage_strategy='memory' (memory only)
[2023/03/28 14:58:32] [ info] [sp] stream processor started
[2023/03/28 14:58:32] [ info] [output:stdout:stdout.0] worker #0 started
[0] cpu.0: [1680015512.686853196, {"cpu_p"=>0.000000, "user_p"=>0.000000, "system_p"=>0.000000, "cpu0.p_cpu"=>0.000000, "cpu0.p_user"=>0.000000, "cpu0.p_system"=>0.000000, "cpu1.p_cpu"=>0.000000, "cpu1.p_user"=>0.000000, "cpu1.p_system"=>0.000000, "cpu2.p_cpu"=>0.000000, "cpu2.p_user"=>0.000000, "cpu2.p_system"=>0.000000, "cpu3.p_cpu"=>0.000000, "cpu3.p_user"=>0.000000, "cpu3.p_system"=>0.000000}]
[0] cpu.0: [1680015513.687115959, {"cpu_p"=>0.000000, "user_p"=>0.000000, "system_p"=>0.000000, "cpu0.p_cpu"=>0.000000, "cpu0.p_user"=>0.000000, "cpu0.p_system"=>0.000000, "cpu1.p_cpu"=>0.000000, "cpu1.p_user"=>0.000000, "cpu1.p_system"=>0.000000, "cpu2.p_cpu"=>0.000000, "cpu2.p_user"=>0.000000, "cpu2.p_system"=>0.000000, "cpu3.p_cpu"=>0.000000, "cpu3.p_user"=>0.000000, "cpu3.p_system"=>0.000000}]