14
BigQuery + Fluentd 2014/12/13 GDG Kyoto 2014 年忘れ勉強会

BigQuery + Fluentd

Embed Size (px)

Citation preview

Page 1: BigQuery + Fluentd

BigQuery + Fluentd

2014/12/13

GDG Kyoto 2014 年忘れ勉強会

Page 2: BigQuery + Fluentd

BigQuery とは...

Google Cloud Platform で 提供されるサービスのひとつ

RDBライクな分散クエリエンジン

巨大なデータベースに対して 高速にクエリ処理できる

他社製品だと,Redshift(AWS), Impala(Cloudera), Vertica(HP) など

Page 3: BigQuery + Fluentd

速さの秘訣①

カラム志向型データベース

3

テーブル 通常のRDBMS

BigQuery

列方向のスキャンが速い! (平均,最大/最小値,...)

Page 4: BigQuery + Fluentd

速さの秘訣②

分散処理

4

クエリ

数千台!

Page 5: BigQuery + Fluentd

お高いんでしょ??

ストレージ料金

容量:$0.02 / GB・月

ストリーム投入:$0.01 / 10万行 (2015年~)

(※MB・秒 単位で計算される)

クエリ料金

オンデマンドタイプの時

• $5 / TB (MB単位)

予約タイプの時

• 月額$2万 / 毎秒5GB

5

Page 6: BigQuery + Fluentd

使い方

Developpers Console (console.developers.google.com) から BigQuery APIを有効にする

6

Page 7: BigQuery + Fluentd

使い方

BigQueryのコンソールに移動して操作

データセットやテーブルの作成・削除

データインポート

クエリ実行

7

Page 8: BigQuery + Fluentd

Fluentd

オープンソースの ログ集約管理ソフトウェア

TresureData製

syslogやログファイルからデータを収集し 集計処理や伝送処理を受け持つ。

8

DB

監視 ツール

Erasticsearch S3 Bigquery ...

Kibana Grafana ...

Page 9: BigQuery + Fluentd

ということで,組み合わせてみる

9

RaspberryPi

BigQuery Python

Page 10: BigQuery + Fluentd

BigQuery のテーブルスキーマ

10

> bq mk -t kosaic-jp:fluent_test.fluent_test schema.json

Google Cloud SDK Shell から

プロジェクト名:データセット名.テーブル名 [ { "name": "time", "type": "TIMESTAMP" }, { "name": "value", "type": "FLOAT" } ]

Page 11: BigQuery + Fluentd

fluentd.conf

11

<source> type forward port 24224 </source> <match test.**> type bigquery method insert auth_method private_key email ~~@developer.gserviceaccount.com private_key_path ~.p12

project kosaic-jp dataset fluent_test table fluent_test time_format %s time_field time fetch_schema true field_integer time </match>

← OAuthの秘密鍵ファイル(P12)パス

← OAuthのメールアドレス

← プロジェクト名

← データセット名

← テーブル名

← タグ

Page 12: BigQuery + Fluentd

Python

12

#!/usr/bin/python import time from fluent import sender from fluent import event FL_TAG="test" # init fluentd sender.setup(FL_TAG) # send data event.Event("metrics", { "value": 6.0 })

Page 13: BigQuery + Fluentd

Demo

13

Page 14: BigQuery + Fluentd

まとめ

14

という記事がQiitaにありましたので 今回試してみました。

詳しいことを知りたいかたは 以下の元記事をごらんください (_ _)

『Raspberry PiからFluentdでBigQueryにデータを送る ウェザーステーションの作り方』 http://qiita.com/kazunori279/items/0f8d827ac9966c9804ab