LoginSignup
1
1

More than 3 years have passed since last update.

ECSでFirelensを使ってsidecar方式で複雑なログ収集を実現する方法

Posted at

aws firelensを使って、ECSのログ収集をする時に以下のような複雑なことをやろうとする場合は自前でfluent bitの設定を変更する必要があって、具体的にはfluent bitの設定を自分で定義してそれを読み込んだコンテナを用意する必要があります。

  • 複数の場所にログを転送する
  • ログを分割する

やり方

1. docker imageを作成する

以下の様に設定ファイルを作ってそれを取り組んだdocker imageを作成してECSで使うパターン。

例えば、docker/fluent-bitディレクトリを作って以下の様にファイルを配置する

Dockerfile
fluent-bit.conf
parser.conf
stream_processing.conf

Docker file内で設定ファイルをADDしていってます。

FROM amazon/aws-for-fluent-bit:latest
ADD fluent-bit.conf /
ADD parser.conf /
ADD stream_processing.conf /

このDockerfileで作ったimageをECS task definitionで起動する。

参考

2. task defで設定ファイルを読み込むパターン

task definitionに設定ファイルを読み込ませるオプションを渡して、その設定ファイルを読み込ませたECS taskを起動させるパターン

task definitnionの中のoptionでextra.confを渡してあげる事で、その設定でfluent bitを起動してくれる。

imageを自分で作って管理する必要がない。

"options": {
    "config-file-type": "s3",
    "config-file-value": "arn:aws:s3:::yourbucket/yourdirectory/extra.conf"
}

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1