http://dev.classmethod.jp/cloud/td-agent2-amazon-linux/
上記ページに沿って行った。CentOSでも同じ手順。
手動で実行するならば以下の通りに実行する
[treasuredata] name=TreasureData baseurl=http://packages.treasure-data.com/redhat/$basearch gpgcheck=0
yum install td-agent
sourceで入力を定義して、matchで処理を行う。
include conf.d/*.conf
# http://localhost:8888/<tag>?json=<json> <source> type http port 8888 </source>
type forwardの場合はhttpアクセスはできないがそのポートで待ち受けすることになる。
| type名 | 簡単な概要 |
| null | 転送せずに捨てる |
| forest | タグ名を置換変数化できるので、まとめて同じような設定をしたいときに使う |
| rewrite_tag_filter | 正規表現でタグづけできる |
| record_modifier | 新たに属性を追加できる。たとえばApacheログにホスト名を付与したりとか |
<source>
type tail
format apache
path /var/log/httpd/*_access_log
tag apache.access
pos_file /tmp/fluentd-apache.pos
</source>
<match apache.access>
type s3
aws_key_id
aws_sec_key
s3_bucket bucket_name
s3_endpoint bucket_name.s3-website-ap-northeast-1.amazonaws.com
path logs/
buffer_path /var/tmp/fluentd
time_slice_format %Y%m%d/%H_apache.log
time_slice_wait 30m
flush_interval 60s // この感覚でS3にputするので一日1440リクエストで危うくクラウド破産!
</match>
<source>
type tail
path /var/log/httpd/error_log
format apache_error
tag apache.error
pos_file /tmp/apache_error.pos
</source>
# 送り先を Fluentd の標準ログへ出力します
<match apache.error>
type stdout
</match>
<source> type tail path /var/log/httpd/access_log pos_file /var/tmp/access_log.pos tag httpd format none </source> # 送り先を Fluentd の標準ログへ出力します <match httpd> type stdout </match>