Log collect with google fluentd

18
Log Collect with Google-fluentd

Transcript of Log collect with google fluentd

Page 1: Log collect with google fluentd

Log Collect with Google-fluentd

Page 2: Log collect with google fluentd

前置

Page 3: Log collect with google fluentd

Purpose?

携帯端末(iOS/Android)の操作ログを収集

操作ログはjson形式

解析基盤は、Google Cloud Logging + Big Query

を利用

Page 4: Log collect with google fluentd

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円

Page 5: Log collect with google fluentd

sums it up

クライアント

httpでサーバーに対し、jsonデータをポスト

サーバー

Fluentdのin-httpでデータ受信

Google Cloud Loggingでログ確認

Google Big Queryでビッグデータ解析

Simple!!

Page 6: Log collect with google fluentd

全体像

Page 7: Log collect with google fluentd

OVERVIEW

Cloud

LoggingBig QuerySmart Phone

HTTP Protocoljson format

fluent-plugin-google-cloud

Streaming Insert

in Compute Engine

② ① ③ ④

Page 8: Log collect with google fluentd

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

Page 9: Log collect with google fluentd

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

Page 10: Log collect with 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

Page 11: Log collect with 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

Page 12: Log collect with google fluentd

③-1.Google Cloud

Logging?Google App Engine & Google Cloud Engineでのログを確認するツール

無料

GUIでの簡単な検索機能

Fluentタグでの絞り込み

BigQuery & Cloud Storageへの連携機能

2015年2月現在αリリース

Page 13: Log collect with google fluentd

③-2.Cloud Logging

Interface

Page 14: Log collect with google fluentd

③-3.Cloud Logging

Interface

Search

Log Data

Fluentd tag

Page 15: Log collect with google fluentd

③-4.How to Send

BigQuery?

Very Simple!!

Page 16: Log collect with google fluentd

④. Confirm BigQuery

完了!!

Page 17: Log collect with google fluentd

所感

Page 18: Log collect with google fluentd

Impression

Cloud Logging ⇒ BigQuery連携は、テーブルが存在しない場合は自動作成される

Fluentdのtagでフィルタできるので便利

既存の知識が使えるので、難易度は低い