Log collect with google fluentd
Transcript of Log collect with google fluentd
Log Collect with Google-fluentd
前置
Purpose?
携帯端末(iOS/Android)の操作ログを収集
操作ログはjson形式
解析基盤は、Google Cloud Logging + Big Query
を利用
Why Big Query?
SQL!
json構造体に対してSQL発行
権限制御されたwebインターフェース
ストリーミングインサート!
ログバッファ容量にやさしい
ストレージ価格が安い!(TB/月)
Microsoft Azure Standard Storage / 約2,500円
Amazon S3 / 約3,300円
Amazon Redshift dw2.large(160GBytes SSD) / 22,600円
Google BigQuery / 約2,000円
sums it up
クライアント
httpでサーバーに対し、jsonデータをポスト
サーバー
Fluentdのin-httpでデータ受信
Google Cloud Loggingでログ確認
Google Big Queryでビッグデータ解析
Simple!!
全体像
OVERVIEW
Cloud
LoggingBig QuerySmart Phone
HTTP Protocoljson format
fluent-plugin-google-cloud
Streaming Insert
in Compute Engine
② ① ③ ④
①-1.Google-fluentd
Google Compute Engineで稼働するfluentd
インストール方法はこちら
https://cloud.google.com/logging/docs/install/com
pute_install
td-agent 2.1.2 相当?
root@td-agent01:/etc/google-fluentd# /usr/sbin/google-fluentd --
version
google-fluentd 0.10.57
①-2.Google-fluentd Setting使用感はfluentdと変わらない
configは/etc/google-fluentd/google-fluentd.conf
root@td-agent01:/etc/google-fluentd# ls -al /etc/google-fluentd/
total 78236
drwxr-x--- 5 root root 4096 Dec 2 21:25 .
drwxr-xr-x 94 root root 4096 Feb 16 06:44 ..
drwxr-x--- 2 root root 4096 Dec 2 21:19 catch-all-inputs.d
-rw-r--r-- 1 root root 80071266 Feb 16 06:18 google-fluentd_1.1.1-0_amd64.deb
-rw-r----- 1 root root 1021 Dec 1 22:53 google-fluentd.conf
-rw-r----- 1 root root 11324 Nov 19 23:56 LICENSE
drwxr-xr-x 2 root root 4096 Feb 16 06:18 pkg
drwxr-xr-x 2 root root 4096 Feb 16 06:19 plugin
-rw-r----- 1 root root 249 Nov 20 18:25 README.md
起動停止はserviceコマンドで
root@td-agent01:/etc/google-fluentd# service google-fluentd
restart
* Restarting google-fluentd google-fluentd
①-3.Google-fluentd
Customin_HTTPプラグインを起動させてみる
TCP Port:8888でサーバーが起動
root@td-agent01:/etc/google-fluentd# cat << EOF > /etc/google-
fluentd/catch-all-inputs.d/in_http.conf
<source>
type http
port 8888
bind 0.0.0.0
body_size_limit 32m
keepalive_timeout 10s
</source>
EOF
root@td-agent01:/etc/google-fluentd# service google-fluentd
restart
* Restarting google-fluentd google-fluentd
②.Client
HTTP通信でjsonを投げ込む
$ curl -X POST -d 'json={"message":"test_message3"}'
http://***.***.***.***:8888/test
Keyが「message」の部分のみ取り込まれる
理想:(できない)
curl -X POST -d ‘json={“action”:“login”,“user”:2}’
http://***.***.***.***:8888/test
現実:(messageだけ入る)
curl -X POST -d 'json={"message":"test_message2","id":"001"}'
http://***.***.***.***:8888/test
③-1.Google Cloud
Logging?Google App Engine & Google Cloud Engineでのログを確認するツール
無料
GUIでの簡単な検索機能
Fluentタグでの絞り込み
BigQuery & Cloud Storageへの連携機能
2015年2月現在αリリース
③-2.Cloud Logging
Interface
③-3.Cloud Logging
Interface
Search
Log Data
Fluentd tag
③-4.How to Send
BigQuery?
Very Simple!!
④. Confirm BigQuery
完了!!
所感
Impression
Cloud Logging ⇒ BigQuery連携は、テーブルが存在しない場合は自動作成される
Fluentdのtagでフィルタできるので便利
既存の知識が使えるので、難易度は低い