43
classmethod.jp 1 Amazon Redshift & Amazon EMR & Tableau Desktop で実現する CloudTrailログ解析 2013/12/10(Tue) at SAP 18:30 - 22:15(EventAllTime) 18:35 - 18:55(EventMyPart) #cmdevio @shinyaa31 1 131211日水曜日

2013.12.10 Classmethod re:Grwoth

Embed Size (px)

DESCRIPTION

下記勉強会での発表スライドです。 【AWS勉強会】CM re:Growth Developers.IO Meetup 01 - connpass http://connpass.com/event/4123/

Citation preview

Page 1: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 1

Amazon Redshift &Amazon EMR &Tableau Desktop

で実現するCloudTrailログ解析

2013/12/10(Tue) at SAP18:30 - 22:15(EventAllTime)18:35 - 18:55(EventMyPart)

#cmdevio@shinyaa31

113年12月11日水曜日

Page 2: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 2

自己紹介・しんや (@shinyaa31)・AWSコンサルティング部所属 ・昔Java、ちょろっとFlex等も ・AWS利用は今年から本格的に。

・個人ブログ(2007.01.01~)  Shinya’s Daily Report http://d.hatena.ne.jp/absj31/・Developers.IO 出張ブロガー  (2013.04.29~)・クラスメソッド AWSエンジニア (2013.08.01~) http://dev.classmethod.jp/author/shinyaa31/

213年12月11日水曜日

Page 3: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 3

自己紹介・割と良くブログを書いています→3560本(個人ブログ, 2007年~現在)

→103本(Developers.IO, 出張時代&入社約4ヶ月間で)

→229本(個人:202 + Developers.IO:24 + 寄稿:3)

→323本(Togetterまとめ数合計)

※2013/12/10現在

→183回(2010.10.21以来現在までの通算参加回数)

・割と良くイベントに参加し、レポートを 書いています

・割と良くまとめています

313年12月11日水曜日

Page 4: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 4

#cmdevioハッシュタグ:

(Classmethod Developers.IO)2013/12/10 CM re:Growth Developers.IO Meetup 01#cmdevio - Togetterhttp://togetter.com/li/592882

413年12月11日水曜日

Page 5: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 5

アジェンダ1.はじめに2.監査ログの設定と出力(CloudTrail)3.ログの成形処理(EMR)4.データウェアハウス管理(Redshift)5.データ照会・分析(Tableau Desktop)6.さいごに

513年12月11日水曜日

Page 6: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 6

1.はじめに<今回の目的(ゴール)>→CloudTrailのログを Tableau Desktopで 閲覧、分析してみたい。

613年12月11日水曜日

Page 7: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 7

環境構成図

713年12月11日水曜日

Page 8: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 8

2.CloudTrail

813年12月11日水曜日

Page 9: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 9

2.CloudTrail・2013/11/13リリース・AWS APIコールを記録、S3にログを保存・各種対応への利用が見込める コンプライアンス対応/リソースライフサイクル管理 トラブルシューティング対応・利用可能リージョン(2013/12/10現在) 米国東リージョン(N.Virginia), 米国西リージョン(Oregon)

・対応サービス(2013/12/10現在) EC2, EBS, VPC, RDS, IAM, STS, Redshift

913年12月11日水曜日

Page 10: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 10

2.CloudTrail・SNS通知設定を事前に作成しておく

SNS:Amazon Simple Notification Serviceプッシュメッセージングサービス。

1013年12月11日水曜日

Page 11: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 11

2.CloudTrail・対応リージョンに移動、[CloudTrail]選択

1113年12月11日水曜日

Page 12: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 12

2.CloudTrail・必要事項記入の後、[Subscribe]で作成

・S3バケット設定・操作対象サービス設定・SNS通知設定

1213年12月11日水曜日

Page 13: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 13

2.CloudTrail・作成完了→ログ生成確認

1313年12月11日水曜日

Page 14: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 14

2.CloudTrail・ログ出力内容<userIdentity>・type・principalId・arn・accountId・sessionContext・invokedBy・sessionIssuer・webIdFederationUser

<RecordBody>・eventTime・eventVersion・eventSource・eventName・awsRegion・sourceIPAddress・userAgent・errorCode・errorMessage・requestParameters・responseElements

1413年12月11日水曜日

Page 15: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 15

3.EMR

1513年12月11日水曜日

Page 16: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 16

3.EMR・Amazon Elastic MapReduce 大量データを迅速且つ容易に コスト効果良く処理する為のサービス・Hadoopデータ分散処理をEC2上で実行・各種分析、ETL、DWH等用途は様々・利用可能なディストリビューション ・Amazon Distribution ・MapR Distribution(M3, M5, M7)

1613年12月11日水曜日

Page 17: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 17

3.EMR・今回、EMRでやりたい事 →ログファイルを良い感じに分割・整形したい。

{"Records":[

{"eventVersion":"1.0","userIdentity":{"type":"IAMUser". …}, … }

{"eventVersion":"1.0","userIdentity":{"type":"IAMUser". …}, … }

{"eventVersion":"1.0","userIdentity":{"type":"IAMUser". …}, … }

:

]}

1.0|IAMUser| ... |ec2.amazonaws.com|DescribeInstances|...

1.0|IAMUser| ... |rds.amazonaws.com|DescribeDBInstances|...

1.0|IAMUser| ... |redshift.amazonaws.com|...

Before

After

1713年12月11日水曜日

Page 18: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 18

3.EMR・Mapper/Reducerプログラムを作成 ・プログラム作成にはRubyを利用 ・Mapper:  →標準入力を受け取る→ログ1行から情報を抽出  →指定文字区切りの情報を1行ずつ標準出力 ・Reducer:  →標準入力をそのまま標準出力へ・プログラム実行:Hadoop Streamingを使用  ※Java以外のプログラムを実行する場合に用いる

1813年12月11日水曜日

Page 19: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 19

3.EMR・EMRクラスタ作成(Step作成)

1913年12月11日水曜日

Page 20: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 20

3.EMR・EMRクラスタ作成(Step作成)

2013年12月11日水曜日

Page 21: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 21

3.EMR・EMRクラスタ作成(クラスタ実行)

2113年12月11日水曜日

Page 22: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 22

3.EMR・EMRクラスタ作成(実行結果確認)

2213年12月11日水曜日

Page 23: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 23

4.Redshift

2313年12月11日水曜日

Page 24: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 24

4.Redshift・Amazon Redshift 高速&管理も安全なDWHサービス・特徴と利点 ・列指向ストレージ技術 ・複数ノード間でのクエリ並列化&分散化 ・各種管理タスクを自動化可能 ・高機能なセキュリティ機能も標準搭載・料金: 1.250$/時 (東京, XLノード2TBストレージ1ノードあたり)

2413年12月11日水曜日

Page 25: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 25

4.Redshift

本日リリース!会員様向けAWSコスト最適化支援サイト『メンバーズポータル』はじめました。 | Developers.IOhttp://dev.classmethod.jp/cloud/aws/members-portal-released/

2513年12月11日水曜日

Page 26: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 26

4.Redshift・Redshiftクラスタ作成(クラスタ詳細)

2613年12月11日水曜日

Page 27: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 27

4.Redshift・Redshiftクラスタ作成(ノード設定)

2713年12月11日水曜日

Page 28: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 28

4.Redshift・Redshiftへアクセス、テーブル作成

※SQL Workbench/J http://www.sql-workbench.net/

2813年12月11日水曜日

Page 29: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 29

4.Redshift・s3からデータをRedshiftへロード

※COPY - Amazon Redshifthttp://docs.aws.amazon.com/redshift/latest/dg/r_COPY.html

COPY (テーブル名)from ‘s3://(バケット名&ファイル名)’CREDENTIALS ‘(認証情報)’delimiter ‘(区切り文字)’dateformat ‘(日付時刻データの形式)’

2913年12月11日水曜日

Page 30: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 30

5.Tableau Desktop

3013年12月11日水曜日

Page 31: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 31

5.Tableau

http://www.tableausoftware.com/ja-jp

・米国Tableau Software社(2003年創業)のBIツール 世界114カ国の1万2000を超える政府機関、教育機関 企業等、産業、業種、規模を問わず幅広く導入・日本展開: 2012年11月にTableau Japan設立・コンセプトは『Excelユーザーなら誰でも使えるツール』・様々な接続データソースに対応、AWS対応も充実(※後述)・用途に応じた製品を展開 ・Desktop (デスクトップ版/有料) ・Server (サーバ版/有料) ・Public (分析データを一般配信・共有/無料) ・Reader (ビューワ/無料)

http://www.atmarkit.co.jp/ait/articles/1305/28/news076.html

3113年12月11日水曜日

Page 32: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 32

5.Tableauローカルファイル Tableauデータ抽出/テキスト

Microsoft Access/Excel等

RDBMS MySQL, Oracle, SQL ServerPostgreSQL, DB2等

DWH Amazon Redshift, SAP HANA,EMC Greenplum, Actian Vectorwise等

Hadoop Cloudera Hadoop, MapR Hadoop Hive, Hortonworks Hadoop Hive等

OLAP Google Analytics, Google BigQuery,Oracle Essbase等

MPP ParAccel, Aster Database等

※Tableauで始めるBI(ビジネス・インテリジェンス):製品&対応データソース一覧 | Developers.IOhttp://dev.classmethod.jp/business/business-analytics/getting-started-tableau-product-and-datasources/

3213年12月11日水曜日

Page 33: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 33

5.Tableau・ダウンロード& インストール http://www.tableausoftware.com/ja-jp/ products/

・JDBCドライバのインストール Drivers & Activation | Tableau Software http://www.tableausoftware.com/support/drivers

※2013年12月現在、Windows版のみ対応

3313年12月11日水曜日

Page 34: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 34

5.Tableau・接続設定

3413年12月11日水曜日

Page 35: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 35

5.Tableau・接続&分析!

例)サービス別利用回数ランキング

3513年12月11日水曜日

Page 36: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 36

5.Tableau・接続&分析! 例)時系列で

利用内容を分類、表示

3613年12月11日水曜日

Page 37: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 37

5.Tableau・接続&分析!

例)円グラフで割合を表示

3713年12月11日水曜日

Page 38: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 38

5.Tableau・接続&分析! 例)表形式で

内容確認

3813年12月11日水曜日

Page 39: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 39

5.Tableau<おまけ>Tableau Publicでこんなグラフも。

2014年ブラジルW杯グループリーグ突破予想

2014 World Cup Group Stage Odds | Tableau Publichttp://www.tableausoftware.com/public/gallery/2014-world-cup-group-stage-odds

3913年12月11日水曜日

Page 40: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 40

5.Tableau<おまけ>Tableau Publicでこんなグラフも。

1900~2013年までのサッカー選手移籍推移をグラフ化

Football Player Transfers (1900 - 2013) | Tableau Publichttp://www.tableausoftware.com/public/gallery/football-player-transfers

4013年12月11日水曜日

Page 41: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 41

5.Tableau<おまけ>Tableau Publicでこんなグラフも。

Top Movie Directors by Film | Tableau Publichttp://www.tableausoftware.com/public/gallery/top-movie-directors-film

映画監督ランキング

4113年12月11日水曜日

Page 42: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 42

6.まとめ・十分な分析・解析を行うためには、『何をどのように分析したいのか』が大事。・用途や目的に応じてツールやサービスを 色々組み合わせて利用。・分析の為には様々な”武器”が必要 ・ETL (Extract/Transform/Load) ・ログ周り、ログ分析周り ・分析手法や分析ツール ・対象分野のビジネス知識・連携自動化重要・目指せ!? データサイエンティスト

4213年12月11日水曜日

Page 43: 2013.12.10 Classmethod re:Grwoth

classmethod.jp 43

ご清聴ありがとうございました。

4313年12月11日水曜日