fluent-bitのコンテナを立ち上げる
目的
- fluent-bitのコンテナを立ち上げる
- 別のコンテナのログを転送する
環境
$ uname -srvmpio
Linux 5.8.0-59-generic #66~20.04.1-Ubuntu SMP Thu Jun 17 11:14:10 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
$ docker -v
Docker version 20.10.7, build f0df350
$ docker-compose -v
docker-compose version 1.26.0, build d4451659
コンテナ作成
docker-compose.yaml
version: '3.8'
services:
fluentbit:
container_name: fluentbit
image: fluent/fluent-bit
volumes:
- ./fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf
ports:
- 24224:24224
Dockerのlogging-driverに指定する
docker-compose.yaml
version: '3.8'
services:
fluent-bit:
container_name: fluent-bit
image: fluent/fluent-bit
command: ["/fluent-bit/bin/fluent-bit", "-c", "/fluent-bit/etc/fluent-bit.conf"]
ports:
- 127.0.0.1:24224:24224
- 127.0.0.1:24224:24224/udp
volumes:
- ./fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf
- ./parsers.conf:/fluent-bit/etc/parsers.conf
http-echo:
image: hashicorp/http-echo:latest
command: ['-text', 'Hello World', '-listen', ':8080']
ports:
- 8080:8080
depends_on:
- fluent-bit
logging:
driver: "fluentd"
options:
fluentd-address: localhost:24224
tag: "docker.logging_driver.mylog"
fluent-bit.conf
[SERVICE]
Flush 5
Daemon Off
Log_Level info
Parsers_File parsers.conf
Plugins_File plugins.conf
[INPUT]
Name forward
Host 0.0.0.0
Listen 0.0.0.0
Port 24224
[OUTPUT]
Name stdout
Match *
Format json_lines
参考資料