LoginSignup
0
0

More than 5 years have passed since last update.

fluentdで集めたログをS3へ

Posted at

メモ:fluentdでログを2箇所に出力する

-ログ集約サーバへの出力
-S3への出力

S3にアーカイブしておくことでログの保管要件を満たしつつ、
ログ集約サーバのストレージサイズを抑える

※ちなみに前回の記事からの発展です
環境、前提は前回を踏襲し、EC2(B)への設定を変更していく。
http://qiita.com/ohayougenki/items/5341b313a2226093480b

前回から追加になった前提

1)EC2(B)はS3へ接続が可能であること
※今回はインターネット経由ですが、VPCエンドポイント、NAT gatewayでもいいかも?(要検証)

2)今回は設定ファイルにアクセスキー/シークレットアクセスキーを直書き。

<source>
  type forward
  port 24224
  bind 0.0.0.0
</source>

<match apache.access>
  type copy
  <store>
    type file
    path /var/log/td-agent/collect/httpd/access.log
    time_slice_format %Y%m%d%H%M ※この設定だと分ごと適宜修正
  </store>
  <store>
    type s3
    aws_key_id <アクセスキー>
    aws_sec_key <シークレットアクセスキー>
    s3_bucket <事前に作成したs3bucket名>
    s3_region <s3bucketのあるリージョン ex)ap-northeast-1>
    buffer_path /var/log/td-agent/s3
    time_slice_format %Y%m%d%H%M ※この設定だと分ごと。適宜修正
  </store>
</match>

一時的にbuffer_pathにS3出力用のログがバッファとしてたまり、
しばらくしたら、S3に配置される。

★汎用性と、階層構造を自動で持ってもらえるように
タグでの管理ができるところまで落とし込みたい。
<時間ができたら書きます。>

バッファの動きについてすごくわかりやすく書いてある。
参照:https://blog.tnmt.info/2012/10/19/about-fluentd-out-file-plugin/

0
0
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
0
0