fluentdを使って、ApacheのアクセスログをS3のバケットにためる手順です。
fluentdの設定が難しくて、なかなか苦労しました。
次回苦労しないように、ここに書き留めておきます。
TreasureDataリポジトリを追加します。
vi /etc/yum.repos.d/treasuredata.repo で次を記述します
[treasuredata]
name=TreasureData
baseurl=http://packages.treasure-data.com/redhat/$basearch
enabled=1
gpgcheck=0
yum install -y td-agent
fluentdの実行ユーザでaccess_logを読めるように権限を設定します。
chgrp td-agent /var/log/httpd/
chmod g+rx /var/log/httpd/
設定ファイルを作成します※赤字の部分は修正してください。
vi /etc/td-agent/td-agent.conf
<source> type tail format apache2 path /var/log/httpd/access_log pos_file /var/log/td-agent/httpd.access_log.pos tag s3.apache.access </source> <match s3.*.*> type copy <store> type s3 aws_key_id AWS-ACCESS-KEY aws_sec_key AWS-SECRET-KEY s3_bucket apache-accesslog s3_endpoint s3-ap-southeast-1.amazonaws.com path access_log_ buffer_path /var/log/td-agent/s3 time_slice_format %Y%m%d_%H%M time_slice_wait 1m utc buffer_chunk_limit 256m </store> </match>
起動します。
/etc/init.d/td-agent start
Apacheにアクセスして、ログがS3のバケット内に作成されればOKです!
0 件のコメント:
コメントを投稿