aws firelensを使って、ECSのログ収集をする時に以下のような複雑なことをやろうとする場合は自前でfluent bitの設定を変更する必要があって、具体的にはfluent bitの設定を自分で定義してそれを読み込んだコンテナを用意する必要があります。
- 複数の場所にログを転送する
- ログを分割する
やり方
extra.confを用意して、用意したファイルを読み込んだコンテナを作成する。
コンテナの作成の仕方はこちらを参照してください。
この記事ではextra.confの書き方だけを残しています。
# cw logs
[OUTPUT]
Name cloudwatch
Match *
region us-east-1
log_group_name fluent-bit-cloudwatch
log_stream_prefix from-fluent-bit-
auto_create_group true
# kinesis
[OUTPUT]
Name firehose
Match *
region us-west-2
delivery_stream stream-one
[OUTPUT]
Name firehose
Match *
region us-west-2
delivery_stream stream-two
Match
の正規表現を作り込むことで例えば、ログレベルごとにログを収集することができます。
また[OUTPUT]
を複数定義することで複数の場所にログを転送することができます。