SlideShare uma empresa Scribd logo
1 de 265
Baixar para ler offline
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Data Lake Hands-on
2
はじめに
幅広いデータソースからの構造化データまたは非構造化データの集中リポジトリとして使用で
きる Data Lake は、データの保存と分析の方法として多くの企業に取り入れられています。
当セミナーでは、AWSのビッグデータ関連サービスを使用して実際に分析パイプラインを構
築することを通して、Data Lake と ビッグデータ分析基盤構築の実感を持って頂くことを
ゴールとしています。
【準備事項】
AWSを利用可能なネットワークに接続されたPC(Windows, Mac OS, Linux等)
事前に用意していただいたAWSアカウント
SSHクライアント(Windows環境ではTera Termを推奨)
ブラウザ(FirefoxもしくはChromeを推奨)
3
はじめに
Assetを以下よりダウンロードしてください。
https://bit.ly/2Pi1pQt
※都合により⑤の手順は削除いたしました。
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ハンズオン概要
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ハンズオン概要
6つのセクション
① はじめの準備(必須)
主に使用するAWSサービス:Amazon VPC, Amazon EC2, AWS CloudFormation, AWS IAM
② アプリケーションログをリアルタイムで可視化する
主に使用するAWSサービス:Amazon Elasticsearch Service
③ アプリケーションログのリアルタイム可視化とアラーム
主に使用するAWSサービス:Amazon CloudWatch, AWS Lambda, Amazon Elasticsearch Service
④ アプリケーションログの永続化と長期間データの分析と可視化
主に使用するAWSサービス:Amazon Kinesis Data Firehose, Amazon S3, Amazon Athena, Amazon QuickSight
⑤ クラウドDWHを使用したデータ分析
主に使用するAWSサービス: Amazon Kinesis Data Firehose, Amazon S3, Amazon Redshift, Amazon Redshift Spectrum,
Amazon QuickSight
⑥ サーバーレスでデータのETL処理
主に使用するAWSサービス:AWS Glue, Amazon Athena
5
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ニアリアルタイムデータ分析環境(スピードレイヤ)
の構築 : ① -> ② -> ③
① はじめの準備
主に使用するAWSサービス:Amazon VPC, Amazon EC2, AWS CloudFormation, AWS IAM
② アプリケーションログをリアルタイムで可視化する
主に使用するAWSサービス:Amazon Elasticsearch Service
③ アプリケーションログのリアルタイム可視化とアラーム
主に使用するAWSサービス:Amazon CloudWatch, AWS Lambda, Amazon Elasticsearch
Service
6
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CloudWatch Logs
Alarm
Lambda
Athena
S3Kinesis Data Firehose QuickSight
Glue S3
Redshift
Elasticsearch
7
ニアリアルタイムデータ分析環境(スピードレイヤ)
の構築 : ① -> ② -> ③
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
長期間のデータをバッチ分析する環境(バッチレイヤ)
の構築と、パフォーマンスとコストの最適化: ① ->
④ or ⑤ -> ⑥
① はじめの準備
主に使用するAWSサービス:Amazon VPC, Amazon EC2, AWS CloudFormation, AWS IAM
④ アプリケーションログの永続化と長期間データの分析と可視化
主に使用するAWSサービス:Amazon Kinesis Data Firehose, Amazon S3, Amazon Athena,
Amazon QuickSight
⑤ クラウドDWHを使用したデータ分析
主に使用するAWSサービス: Amazon Kinesis Data Firehose, Amazon Redshift, Amazon
Redshift Spectrum, Amazon QuickSight
⑥ サーバーレスでデータのETL処理
主に使用するAWSサービス:AWS Glue, Amazon Athena
8
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CloudWatch Logs
Alarm
Lambda
Athena
S3Kinesis Data Firehose QuickSight
Glue S3
Redshift
Elasticsearch
9
長期間のデータをバッチ分析する環境(バッチレイヤ)
の構築と、パフォーマンスとコストの最適化: ① ->
④ or ⑤ -> ⑥
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
すべて実施 : ① -> ② -> ③ -> ④ -> ⑤ -> ⑥
① はじめの準備
主に使用するAWSサービス:Amazon VPC, Amazon EC2, AWS CloudFormation, AWS IAM
② アプリケーションログをリアルタイムで可視化する
主に使用するAWSサービス:Amazon Elasticsearch Service
③ アプリケーションログのリアルタイム可視化とアラーム
主に使用するAWSサービス:Amazon CloudWatch, AWS Lambda, Amazon Elasticsearch Service
④ アプリケーションログの永続化と長期間データの分析と可視化
主に使用するAWSサービス:Amazon Kinesis Data Firehose, Amazon S3, Amazon Athena, Amazon
QuickSight
⑤ クラウドDWHを使用したデータ分析
主に使用するAWSサービス: Amazon Kinesis Data Firehose, Amazon S3, Amazon Redshift, Amazon
Redshift Spectrum, Amazon QuickSight
⑥ サーバーレスでデータのETL処理
主に使用するAWSサービス:AWS Glue, Amazon Athena
10
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
すべて実施した場合の最終構成
CloudWatch Logs
Alarm
Lambda
Athena
S3Kinesis Data Firehose
スピードレイヤでニアリアルタイム分析を行いながら、特定の条件時にアラームを飛ばしつ
つ、すべてのログデータを安価に長期保存しながら、必要に応じてETL処理を行った上で、
アドホックにログデータに直接クエリしならがら分析すべきデータを見極めつつ、DWHで細
かく分析を行うと同時に、BIツールで可視化する構成を、ほぼサーバレスで実現する。
QuickSight
Glue S3
Redshift
Elasticsearch
11
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
①はじめの準備
ログを生成し続けるEC2を作成する。CloudFormationからVPCやEC2を構築し、
手動でFluentdをインストールする。IAMロールを1つ作成しEC2にアタッチする。
12
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
②アプリケーションログをリアルタイムで可視化する
EC2で出力されるログをOSSのFluentdを使ってストリームでAmazon ESに転送
Amazon ESに付属しているKibanaでグラフィカルにデータを見る。
Elasticsearch
13
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
③アプリケーションログのリアルタイム可視化と
アラーム
CloudWatch Logs
Alarm
Lambda
ストリームの間にCloudWatchを入れリアルタイムログ監視を行う。
Elasticsearch
14
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
④アプリケーションログの永続化と長期間データの分析
と可視化
AthenaS3Kinesis Data Firehose
ストリーミングデータを直接データストアに永続化し、
長期間の保存を可能にした上で、アドホックな分析を行い、
BIツールで可視化する。
QuickSight
15
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
S3Kinesis Data Firehose
ストリーミングデータを直接データストアに永続化し、
長期間の保存を可能にした上で、DWHに読み込み分析し、
BIツールで可視化する。
Redshift
Redshift Spectrum
⑤クラウドDWHを使用したデータ分析
16
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
⑥サーバーレスでデータのETL処理
Athena
S3Kinesis Data Firehose Glue S3
Glueを使ってデータの加工処理をサーバーレスで行う
 ファイルフォーマットを”parquet”に変更
 ファイルをパーティショニングした配置
Redshift
spectrum
17
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
すべて実施した場合の最終構成
CloudWatch Logs
Alarm
Lambda
Athena
S3Kinesis Data Firehose
スピードレイヤでニアリアルタイム分析を行いながら、特定の条件時にアラームを飛ばしつ
つ、すべてのログデータを安価に長期保存しながら、必要に応じてETL処理を行った上で、
アドホックにログデータに直接クエリしならがら分析すべきデータを見極めつつ、DWHで細
かく分析を行うと同時に、BIツールで可視化する構成を、ほぼサーバレスで実現する。
QuickSight
Glue S3
Redshift
Elasticsearch
18
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
①はじめの準備
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
①はじめの準備
ログを生成し続けるEC2を作成する。CloudFormationからVPCやEC2を構築し、
手動でFluentdをインストールする。IAMロールを1つ作成しEC2にアタッチする。
※東京リージョンで実施
20
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“キーペア” がない場合新規で作成します。AWSマネージメントコンソールから”EC2”をクリック
”キーペア”をクリック、[キーペア作成]をクリック、”キーペア名”を入力し[作成]をクリック
操作しているパソコンに秘密鍵(handson.pem)がダウンロードされます
(1)SSHログイン方法(キーペアの作成)
キーペアが既にある方は
飛ばしてください。
21
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(1)SSHログイン方法
必要なもの
• インスタンス作成時に指定したキーペアの秘密鍵ファイル (handson.pem)
• インスタンスに割当たるパブリックIP
SSHログイン方法
(具体的な操作方法は次ページより説明しています)
• 接続先ホスト:インスタンスに割当たるパブリックIP
• ログインユーザ名: ec2-user
• 接続方法:公開鍵暗号方式(秘密鍵ファイルを指定)
この後SSHログインと出てきたら以下の手順で進めてください
22
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Windowsからログインする場合
• TeraTerm (ttssh.exe) を起動 http://sourceforge.jp/projects/ttssh2/
• 1.接続するインスタンスのパブリックDNS名を入力
• 2.SSH2を指定
• 3.「OK」をクリック
• 4.この画面が出たら「続行」をクリック
→
1
2
3 4
(1)SSHログイン方法
23
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
• ユーザ名: ec2-user
• 「RSA/DSA/ECDSA/ED25519鍵を使う」を選択
• 秘密鍵ファイル(handson.pem)を選択して接続
→→
1
2 3
5
6
7
4. すべてのファイル(*.*)を選択する
(選択しないと鍵が表示されない)
補足)この認証画面で時間が掛かりすぎた場合、タイムアウトに
より「OK」をクリックしても繋がらない場合があります。その場合
は再度Teratermを起動してやり直してください。
(1)SSHログイン方法
24
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Mac/Linuxからログインする場合
• ターミナルからコマンドラインでログイン (事前に秘密鍵
(pemファイル)のパーミッションを600にしないと接続出来
ません)
$ chmod 600 ~/Downloads/handson.pem
$ ssh -i ~/Downloads/handson.pem ec2-user@割当てたパブリックIPアドレス
(1)SSHログイン方法(Macの場合)
25
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
 インスタンスは完全に起動完了しているか?
 起動時に指定した内容どおりに起動しているか?
 接続先のIPアドレス あるいは ホスト名は正しいか?
 指定したSecurity Groupは 22(SSH) や 3389 (RDP) を有効にしているか?
 指定したKey Pairと対応する鍵ファイルを指定しているか?
 秘密鍵ファイルのパーミッションは600になっているか?(Mac/Linuxから)
(1)SSHログインがうまくいかない時
26
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CloudFormationを使いVPCの作成とログを出力し続けるEC2をこのVPCに構築
2分おきに10件前後のログを出力、10分おきに300件のエラーログを出力
(2)ログを生成するEC2を作成
security group
VPC
27
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWSマネージメントコンソールから”CloudFormation”を選択し、 [スタックの作成]をクリック
(2)EC2を1台CloudFormationで構築
28
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“テンプレートの選択“->”テンプレートをS3にアップロード”->[ファイルを選択]をクリックし、
ダウンロードしたテンプレート(1-minilake_ec2.yaml)を指定し[次へ]をクリック
(2)EC2を1台CloudFormationで構築
利用Asset (asset1の”1-minilake_ec2.yaml”)
29
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“スタックの名前”に”handson-minilake”(任意)、“キーペア”は任意のキーペアを指定して
[次へ]をクリック。
(2)EC2を1台CloudFormationで構築
既にキーペア作成済なら、
任意のキーペアでも構い
ません
30
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“オプション”の”タグ”で、”キー”に Name “値”に handson-minilake と入力し、[次へ]。
最後の確認ページで[作成]をクリック。
数分ほど待つとEC2一台ができあがり/root/es-demo/testapp.logにログ出力が始まる
(2)EC2を1台CloudFormationで構築
31
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
EC2へのsshログインしてrootにスイッチし、ログが2分おきに出力していることを確認
※画面はこの後も使うので開いたままにしておいてください。
$ sudo su -
$ tail -f /root/es-demo/testapp.log
(2)EC2を1台CloudFormationで構築
32
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)EC2の設定
 IAMロール作成とEC2にアタッチ
 Fluentd のインストール
33
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)EC2の設定(IAMロール作成とEC2にアタッチ)
demo-minilakeでロール作成
EC2からAmazonESfullアクセスを付与
作成したロールをEC2にアタッチ
EC2にAmazon ESにアクセスするためのIAM ロール作成
AWSマネージメントコンソールから”IAM”を選択し、”ロール”をクリック[ロールの作成]
をクリックする
34
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
”AWSサービス”をクリックし、[EC2]をクリック、[次のステップ: アクセス権限]をクリック
(3)EC2の設定(IAMロール作成とEC2にアタッチ)
35
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
そのまま[次のステップ:確認]をクリック
※この段階ではポリシーなしでロールを作ります
(3)EC2の設定(IAMロール作成とEC2にアタッチ)
36
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“ロール名”に”handson-minilake”と入力し、[ロールの作成]をクリック
(3)EC2の設定(IAMロール作成とEC2にアタッチ)
37
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWSマネージメントコンソールから”EC2”を選択し、”インスタンス”をクリックし、
今回作成したインスタンス(handson-minilake)にチェックを入れ、
[アクション]->”インスタンスの設定”->”IAMロールの割り当て/置換”をクリック
(3)EC2の設定(IAMロール作成とEC2にアタッチ)
38
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“IAMロール”で”handson-minilake”を選び、[適用]をクリック
(3)EC2の設定(IAMロール作成とEC2にアタッチ)
39
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)EC2の設定
 IAMロール作成とEC2にアタッチ
 Fluentd のインストール
40
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)EC2の設定 (Fluentd)
ログ収集ツールFluentdのインストール
41
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)EC2の設定 (Fluentd)
Fluentdとは
 Treasure Dataが開発したOSS
 Ruby製ツール
 軽量
 ログの収集、変換、転送
 特に日本で人気
 Pluggableなので拡張可能で様々なデータストアにリアルタイムログ転送
 バッファリング、再送処理などの機能
※ https://td-agent-package-browser.herokuapp.com/3/redhat/6/x86_64
42
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)EC2の設定 (Fluentd)
SSHログインし以下の設定を行う
利用Asset(asset1の”1-cmd.txt”コマンドリファレンス)
• 以下コマンドを実行
 redhat-lsb-coreとgccをインストール
# yum -y install redhat-lsb-core gcc
 td-agentをインストールする
# rpm -ivh
http://packages.treasuredata.com.s3.amazonaws.com/3/redhat/6/x86_64/td-
agent-3.1.1-0.el6.x86_64.rpm
• /etc/init.d/td-agentの18行目修正
TD_AGENT_USER=td-agentからTD_AGENT_USER=rootに編集
• Fluentdの自動起動設定(実際の起動は後ほど行います)
# chkconfig td-agent on
43
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
②アプリケーションログをリアルタ
イムで可視化する
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
②アプリケーションのログをリアルタイムで可視化する
EC2で出力されるログをOSSのFluentdを使ってストリームでAmazon ESに送信
Amazon ESに付属しているKibanaでグラフィカルにデータを見る
45
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon Elasticsearch Service
特徴 ( https://aws.amazon.com/jp/elasticsearch-service/ )
• ElasticsearchのAPIをそのまま利用可能
• AWSのサービスと連携した構成を簡単に構築
例)
• CloudWatch Logs -> Lambda -> Amazon ES
• DynamoDB Streams -> Logstash -> Amazon ES
• 検索ドメインを作成すると同時にKibanaが利用可能
• 日本語解析に対応
• Elasticsearch ICUプラグイン
• Elasticsearch Kuromojiプラグイン
価格体系 ( https://aws.amazon.com/jp/elasticsearch-service/pricing/ )
• Elasticsearchインスタンス時間
• Amazon EBSストレージ
ELK(Elasticsearch, Logstash, Kibana)スタックをサポートした
マネージドAnalyticsサービス
Logstash Amazon ESData Source
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
②アプリケーションのログをリアルタイムで可視化する
2分おきに10件前後、10分おきに300件出力され続けるログを、Fluentdを使って
AmazonESに転送しKibanaで可視化する
47
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(1)Amazon ESの作成
AWSマネージメントコンソールから”Elasticsearch Service”を選択し
[新しいドメインの作成]をクリック
48
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(1)Amazon ESの作成
ドメイン名:handson-minilake
バージョン:6.2
上記入力し[次へ]をクリック
49
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(1)Amazon ESの作成
インスタンスタイプを無料枠対象である”t2.small.elasticsearch”を選ぶ
他はそのままにし画面右下の[次へ]をクリック
50
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(1)Amazon ESの作成
ネットワーク構成を[パブリックアクセス]を選び、
ドメインアクセスポリシーの設定を[ドメインへのオープンアクセスを許可]を選ぶ
51
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(1)Amazon ESの作成
注意事項が出ます。この設定は本番環境では推奨いたしません。
今回はハンズオンのため機密データも取り扱わないのでセキュリティをゆるくしてあります。
[リスクに同意します]にチェックを入れ[OK]をクリック、続けて[次へ]をクリック
52
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(1)Amazon ESの作成
[確認]をクリックします。Amazon ESの作成が始まります。
構築完了には10分ほどかかりますが完了を待たずに次の手順を進めてください。
53
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)EC2の設定
 IAMロールにポリシー追加
 Fluentd の設定
54
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)IAM ロールにポリシー追加
作成済の”handson-minilake”のIAMロールに以下のポリシーを追加
 AmazonESFullAccess
AWSマネージメントコンソールから”IAM”を選択し、[ロール]をクリック
[handson-minilake]のロール名をクリック
55
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)IAM ロールにポリシー追加
[ポリシーのアタッチ]をクリック
56
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
検索窓で”amazones”と入れ検索し、 “AmazonESFullAccess”に
チェックを入れ、[ポリシーのアタッチ]をクリック
(2)EC2の設定(IAMロール作成とEC2にアタッチ)
57
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)IAM ロールにポリシー追加
正しくポリシーがアタッチされたことを確認する
 AmazonESFullAccess
58
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)EC2の設定
 IAMロールにポリシー追加
 Fluentd の設定
59
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)EC2の設定
ログ収集ツールFluentdの設定
60
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)EC2の設定 (Fluentd)
利用Asset(asset2の”2-cmd.txt”コマンドリファレンス)
• 以下のコマンドを実行
 Elasticsearchプラグインインストール
# td-agent-gem install –v 2.6.0 fluent-plugin-elasticsearch
 プラグインインストール確認
# td-agent-gem list | grep plugin-elasticsearch
fluent-plugin-elasticsearch (2.6.0, 2.4.0)
61
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)EC2の設定 (Fluentd)
AmazonESのエンドポイントをエディタなどにコピーしておく
(画面の赤枠内でhttps://は含めない)
利用Asset(asset2の”2-td-agent.conf” Fluentdの設定ファイル)
• /etc/td-agent/td-agent.confの中身を削除(vimで開きコマンド “:%d” などで削除)、asset2
にある2-td-agent.confをエディタで開き中身をコピーして貼り付ける。貼り付けたあと内容
を一部修正、eshostをコピーしておいたエンドポイントで置き換え保存する
https://以外の部
分をコピペ
62
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)EC2の設定 (Fluentd)
利用Asset(asset2の”2-cmd.txt”コマンドリファレンス)
• 以下のコマンド実行
# /etc/init.d/td-agent start
• Fluentdのログ確認
# tail -f /var/log/td-agent/td-agent.log
上記ログにエラーが出続けるなどないことを確認
起動に成功した場合、以下の文言が出力されます
[info]: #0 Connection opened to Elasticsearch cluster => { ….
※ログが出るまで少し時間かかる場合があります
63
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)EC2の設定 (Fluentd)
AWSマネージメントコンソールから”Elasticsearch Service”を選択し
作成したhandson-minilakeの設定の状態が”アクティブ”で検索可能なドキュメント
の件数が1以上になっていることを確認し、[handson-minilake]ドメインをクリックする
64
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)Kibanaの設定
”Kibana”の右のURLをクリックする
65
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)Kibanaの設定
Kibanaの左側メニューの”Management”をクリックし、右側の”Index Patterns”
をクリック
66
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)Kibanaの設定
“Index Pattern”に”testappec2log-*”を入力し、右側の[Next step]をクリック
67
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)Kibanaの設定
“Time Filter field name”に”@timestamp”を選択し、右下の[Create index pattern]
をクリック
68
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)Kibanaの設定
利用Asset(asset2の” 2-visualization.json”,” 2-dashboard.json” Kibanaテンプレート)
[Management]をクリックし”Saved Objects”をクリック
[Import]をクリックし、asset2の以下2つを順番にインポートする。何度か確認のウインドウが
出るが[Yes, overwrite all objects]をクリックと、[Confirm all changes]をクリックし進める
 2-visualization.json
 2-dashboard.json ↓以下はインポート後の画面
69
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)Kibanaの設定
[Dashboard]をクリックしインポートした”test1-dashboard”をクリック
以下のように値が表示されていればOK
70
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)Kibanaの設定
右上でタイムレンジが選べる。期間を1時間にしてみる
グラフ表示が1時間の間の取得値に変化している
71
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)Kibanaの設定
[Discover]をクリックし、その右のメニューの[alarmlevel]をクリック
アラームレベルごとの割合が見える
72
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)Kibanaの設定
”alarmlevel”の右のaddをクリックする。同じようにuserの右側のaddをクリックする
対象のカラム(時間、alarmlevel、user)だけが表示される
※”add”はカーソルがある時にだけ表示される
73
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)Kibanaの設定
検索窓に以下を入力しエンターを押すと、”imai”というユーザーでフィルタリングされる
user:”imai”
※検索窓右側の”Uses lucene query syntax”をクリックするとその他様々なクエリシンタックスが確認できます
74
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)Kibanaの設定
• グラフ作成
http://mamelog.hatenablog.jp/entry/2017/03/04/161709
• 検索方法
https://qiita.com/toyama0919/items/9681ae866ce23a637316
• 検索窓に以下を入れて検索してみてください。
host: “prd-web002”
• Kibana Console
RESTのやり取りを直接インタラクティブに実行
例:GET /testapp-2018.02.20/testapplog/_search{ "query": { "match": { "user": "imai" } }}
好きなようにさわってみてください。
Enjoy Kibana!
75
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
②【まとめ】
EC2からのログをストリームでAmazonESに送り、Kibanaで可視化して
エラーログなどを探しやすくなりました。
大量のEC2がある場合ログを探すのは大変なのでさらに高い効果が見込めます
76
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
②【もっと活用】
ログのストリーミングという考え方はAuto Scalingと相性がいい。AutoScalingはコスト圧縮も
できる優れたソリューションだが、何も考慮しないとスケールイン時にログが消えてしまう
ストリーミングでリアルタイムにログを出力することで解決!
77
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(オプション1)Amazon ESへのアクセス制限
特定のIPアドレスからだけにアクセス制限を加える場合は、[アクセスポリシーの変更]
をクリックします。
78
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(オプション1)Amazon ESへのアクセス制限
[特定のIPからのドメインへのアクセスを許可]をクリックし、許可したいIPアドレスを
カンマ区切りで入力します。今回であればログを送るEC2のEIPとKibanaにアクセス
するオフィスのグローバルIP (IPアドレスは”自分のIP”などで検索してみてください)が
該当します。
79
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(補足)Amazon ESのアップグレード New
Amazon ES のダウンタイムなしでアップグレード可能になりました。
バージョン6.x -> バージョン6.3
バージョン5.6 -> バージョン6.3
バージョン5.x -> バージョン5.6
80
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWSマネージメントコンソールから”Elasticsearch Service”を選択し
現在のバージョンが6.2であることを確認し、[handson-minilake]ドメインをクリックする
(オプション2)Amazon ES のin-placeアップグレード
81
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
[ドメインのアップグレード]をクリックする
(オプション2)Amazon ES のin-placeアップグレード
82
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
[ドメインのアップグレード]の画面で“アップグレードの適格性の確認”にチェックを入れ、
[送信]をクリックする。
(オプション2)Amazon ES のin-placeアップグレード
83
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
アップグレードのポップアップが出て、アップグレード中は読み書き出来るが設定変更は
できない旨が表示される。[続行]をクリックする。
(オプション2)Amazon ES のin-placeアップグレード
84
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
数秒”アップグレード処理中”のステータスになりますがすぐ完了します。”アップグレード履歴“
タブをクリックしアップグレードの適格性の確認が”成功”したことを確認します。
(オプション2)Amazon ES のin-placeアップグレード
85
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
アップグレードを行います。”アップグレード“にチェックを入れ、[送信]をクリックし、
ポップアップ画面で[続行]をクリックします。
(オプション2)Amazon ES のin-placeアップグレード
86
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
ステータスが”アップグレード処理”に変わります。アップグレードは、
アップグレードの適格性の確認->スナップショットの作成->アップグレード の順で進みます。
(オプション2)Amazon ES のin-placeアップグレード
87
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
10数分かかるので次の作業進めてください。完了すると以下のようになります。
(オプション2)Amazon ES のin-placeアップグレード
88
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
③アプリケーションログのリアルタ
イム可視化とアラーム
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
③アプリログのリアルタイム可視化とアラーム
CloudWatch Logs
Alarm
Lambda
ストリームの間にCloudwatchを入れリアルタイムログ監視を行う
90
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
③アプリログのリアルタイム可視化とアラーム
CloudWatch Logs
Alarm
Lambda
ストリームの間にCloudwatchを入れリアルタイムログ監視を行う
監視 モニタリング
91
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(1)IAM ロールにポリシー追加
作成済の”handson-minilake”のIAMロールに以下のポリシーを追加
 CloudWatchLogsFullAccess
AWSマネージメントコンソールから”IAM”を選択し、[ロール]をクリック
[handson-minilake]のロール名をクリック
92
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(1)IAM ロールにポリシー追加
[ポリシーのアタッチ]をクリック
93
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(1)IAM ロールにポリシー追加
検索などを使いながら以下のポリシーを探してアタッチする
 CloudWatchLogsFullAccess
94
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)EC2の設定変更 (Fluentd)
SSHログインし以下の設定を行う
利用Asset(asset3の”3-cmd.txt” コマンドリファレンス)
・以下のコマンドを実行
-cloudwatchlogsプラグインをインストール
td-agent-gem install fluent-plugin-cloudwatch-logs -v 0.4.4
-プラグインインストールの確認
td-agent-gem list | grep cloudwatch-logs
fluent-plugin-cloudwatch-logs (0.4.4)
95
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)EC2の設定変更 (Fluentd)
利用Asset(asset3の”3-td-agent.conf” Fluentdの設定ファイル)
・/etc/td-agent/td-agent.confの中身を削除(viのコマンドの “:%d” などで削除)し、
asset3にある3-td-agent.confをエディタで開き中身をコピーして貼り付ける。
利用Asset(asset3の”3-cmd.txt “ コマンドリファレンス)
・/etc/init.d/td-agentの先頭に以下の行を追加する(13行目)
export AWS_REGION="ap-northeast-1"
・fluentdリスタート
/etc/init.d/td-agent restart
・fluentdのログ確認
tail -f /var/log/td-agent/td-agent.log
上記ログでエラーが出続けるなどないことを確認
96
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)CloudWatch Logsの設定
AWSマネージメントコンソールから”CloudWatch”を選択し、”ログ”をクリック
ロググループ”minilake_group”が出力されていることを確認しクリック
※数分待ってもログが出ない場合はEC2にIAMロールがアタッチされてるか確認
97
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)CloudWatch Logsの設定
ログストリーム”testapplog_stream”をクリック
直近のログが出力されていることを確認
画面上部の”ロググループ”の文字列をクリックしロググループに戻る
98
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)CloudWatch Logsの設定
ロググループ”minilake_group”にチェックを入れ、[アクション]をクリックし
[Amazon Elasticsearch Serviceへのストリーミングの開始]をクリック。
※裏側では自動でLambda Functionが作られます。
99
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)CloudWatch Logsの設定
Amazon ESクラスターを、先に作った”handson-minilake”を選び
Lambda IAM 実行ロールを、[新しいIAMロールの作成]を選択
※ブラウザでポップアップブロックが走ったら、許可して、1つ前のスライドからやり直して下さい
100
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)CloudWatch Logsの設定
”lambda_elasticsearch_execution”という名前のロールが作られるので
そのまま右下の[許可]をクリック
101
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)CloudWatch Logsの設定
[次へ]をクリック
102
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)CloudWatch Logsの設定
ログの形式に[その他]を選択し[次へ]をクリック、その後も[次へ]をクリック
[ストリーミングの開始]をクリック
103
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)ログの転送状況をKibanaから確認
Kibanaの画面を開き、[Management]をクリック、[Index Patterns]をクリック
104
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)ログの転送状況をKibanaから確認
[Create Index Pattern]をクリック
105
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)ログの転送状況をKibanaから確認
“Index pattern”に”cwl-*”を入力、[Next step]をクリック
※[Next step]がクリックできるようになるまで、少し時間がかかる場合があります
106
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)ログの転送状況をKibanaから確認
“Time Filter field name” に”@timestamp” を選択し、[Create index pattern]をクリック
107
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)ログの転送状況をKibanaから確認
[Discover]をクリック、その右のIndexを選ぶ箇所で”cwl-*”を選択する
値が取得されグラフが表示されていればOK
108
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)Kibanaの設定
“Management”をクリックし”Saved Objects”をクリック
利用Asset(asset3の” 3-virtualize.json “,” 3-dashboard.json” Kibanaテンプレート)
画面右上の[Import]をクリックし、ダウンロードしたasset3の以下2つを順番にインポートする
何度か確認のウインドウが出るが[Yes, overwrite all objects]をクリックと、
New index patternに”cwl-*”を選び[Confirm all changes]をクリックで進める。
※LambdaFunctionを修正してない場合は”cwl-*”
 3-virtualize.json
 3-dashboard.json
↓以下はインポート後の画面
109
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(5)CloudWatchAlarm設定
AWSマネージメントコンソールから”CloudWatch”を選択し、”ログ”をクリック
“minilake_group”のロググループにチェックを入れ[メトリクスフィルタの作成]をクリック
110
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(5)CloudWatchAlarm設定
フィルタパターンに”ERROR”を入力。
”パターンのテスト”で確認し、
右下の[メトリクスの割り当て]をクリック
111
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(5)CloudWatchAlarm設定
“メトリクス名”を”minilake_errlog”と入力し[フィルタの作成]をクリック
112
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(5)CloudWatchAlarm設定
フィルタが作成される。右側の”アラームの作成”をクリックし続けてアラーム設定を行う
113
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(5)CloudWatchAlerm設定
• “名前”を”minilake_errlog”
• “閾値”を”50”以上
• 間隔を”1分間”
• アクションの通知を“新しい
リスト”をクリックし、”通知の
送信先“に任意の文字列、”
メールリスト”に受信できる
メアドを入力
上記入力し[アラームの作成]
をクリックする
114
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(5)CloudWatchAlarm設定
確認のメールが送信されているので、メールを確認しリンクをクリックし
”Confirm Subscription”する
115
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(5)CloudWatchAlarm設定
“CloudWatch”の”アラーム”をクリック、最初は状態が”データ不足”と表示されているが、
しばらくすると”OK”になる。1分間で50件以上”ERROR”が発生するとアラートが上がる。
10分ごとにERRORが300件出る設定になっているので10分毎にアラートが上がる
116
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
③【まとめ】
CloudWatch Logs
Alarm
Lambda
以上でリアルタイムなモニタリングとログ監視ができました
117
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
③【もっと活用】
CloudWatchの機能でログの監視・モニタリングは数クリックでとても簡単にできます
CloudWatch Logsにどんなログが
出力されているでしょうか・・?
CloudWatch Logs
Alarm
Lambda
一例を上げます
• Lambdaのログ
• ECSのログ
• Glueのログ
• CloudTrailのログ
• VPC Flow Logsのログ
などなど
これらは全て同様の手順でアラーム設定、リアルタイムモニタリングが可能です
多くのAWSマネージドサービスがCloudWatch Logsにログ出力しています
118
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(オプション)cwl-*では分かりづらいので修正
以下の修正をしたい場合、自動で作成されたLambda Functionを修正します
 “cwl-*”ではわかりずらいので変更したい
 @messageは全文なので不要な場合
【修正前】
119
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWSマネージメントコンソールから”Lambda”を選択し、自動で作られたLambda関数
の”LogsToElasticsearch_handson-minilake”をクリックしコードを編集し[保存]をクリックする
 “cwl-”->”testappcwllog-” (64行目)
 @messageの行を削除 (71行目)
【修正後】
(オプション)cwl-*では分かりづらいので修正
120
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
”Management”をクリック、[Create Index Pattern]をクリックし“Index Pattern”に
”testappcwllog-*”を入力し[Next step]をクリックし、次に[Create index pattern]を
クリックする
【修正後】
(オプション)cwl-*では分かりづらいので修正
121
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“Discover”から、新たに作成したIndexでグラフ表示出来ていることを確認
【修正後】
(オプション)cwl-*では分かりづらいので修正
122
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“Management”をクリックし”Saved Objects”をクリック
利用Asset(asset3の” 3-virtualize.json “,” 3-dashboard.json” Kibanaテンプレート)
画面右上の[Import]をクリックし、ダウンロードしたasset3の以下2つを順番にインポートする
何度か確認のウインドウが出るが[Yes, overwrite all objects]をクリックと、
New index patternに”testappcwllog-*”を選び[Confirm all changes]をクリックで進める。
※LambdaFunctionを修正してない場合は”cwl-*”
 3-virtualize.json
 3-dashboard.json
↓以下はインポート後の画面
(オプション)cwl-*では分かりづらいので修正
123
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
④アプリケーションログの永続化と
長期間データの分析と可視化
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
④アプリログの永続化と長期間データへの分析と可視化
AthenaS3Kinesis Data Firehose
ストリーミングデータを直接データストアに永続化し、
長期間の保存を可能にした上で、アドホックな分析・可視化を行う
QuickSight
125
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AthenaS3Kinesis Data Firehose
④アプリログの永続化と長期間データへの分析と可視化
QuickSight
アドホックな
分析・可視化
データ永続化
ストリーミングデータを直接データストアに永続化し、
長期間の保存を可能にした上で、アドホックな分析・可視化を行う
126
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(1)S3バケットを作成
AWSマネージメントコンソールから”S3”を選択し、画面の[バケットを作成する]
をクリックする
127
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(1)S3バケットを作成
バケット名に以下を入力し
左下の[作成] をクリック
“20180315-handson-minilake-ueharaxx”
ueharaのところはご自身の名字
xxにはご自身の誕生日の日にち
※S3バケット名はグローバルで一意である必要
があるので、バケット作成ができればバケット名
は任意でも構いません
128
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)Kinesis Data Firehose作成
AWSマネージメントコンソールから”Kinesis”を選択し、
Kinesis Firehose 配信ストリームの[配信ストリームを作成する]をクリックする
129
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)Kinesis Data Firehose作成
Delivery stream nameに”minilake1”と入力し、[Next]をクリック
130
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)Kinesis Data Firehose作成
“Record transformation”をDisableのまま[Next]をクリック
131
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)Kinesis Data Firehose作成
“Destination”でS3を選び
132
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)Kinesis Data Firehose作成
“S3 bucket”は(1)で作ったバケットを選択。”Prefix”に”minilake-in1/”を入力、S3への出力時
のディレクトリとなりデフォルトだと指定プレフィックス配下に”YYYY/MM/DD/HH”が作られる。
最後に[Next]をクリック
133
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)Kinesis Data Firehose作成
“Buffer interval”を”60”secondsにする。バッファリングは、Buffer sizeかBuffer interval
のいずれかの条件がみたされるとS3に配信されます
今回は設定しませんが、
データの圧縮、暗号化も
可能です。大規模データ
やセキュリティ要件に対し
て有効に働きます
134
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)Kinesis Data Firehose作成
“IAM role”で”Create new,or choose”をクリックし、FirehoseがS3にアクセスするための
IAM ロールを作成します。
135
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)Kinesis Data Firehose作成
作成するIAMロールの情報が表示、“ポリシードキュメントを表示”箇所をクリックする
とポリシー内容が確認できます。 [許可]をクリックします。
136
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)Kinesis Data Firehose作成
[Next]をクリックします。次にReview画面になりますので設定値が問題なければ
[Create delivery stream]をクリックします。
137
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)Kinesis Data Firehose作成
“Status”が”Creating”となります。数分で”Active”になるので次の手順に進めてください
138
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)IAM ロールにポリシー追加
作成済の”handson-minilake”のIAMロールに以下のポリシーを追加
 AmazonKinesisFirehoseFullAccess
AWSマネージメントコンソールから”IAM”を選択し、[ロール]をクリック
[handson-minilake]のロール名をクリック
139
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)EC2側の設定変更
 IAMロールにポリシー追加
 Fluentd の設定
140
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)IAM ロールにポリシー追加
[ポリシーのアタッチ]をクリック
141
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)IAM ロールにポリシー追加
検索などを使いながら以下のポリシーを探してアタッチする
 AmazonKinesisFirehoseFullAccess
142
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)EC2側の設定変更
 IAMロールにポリシー追加
 Fluentd の設定
143
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
利用Asset(asset4の”4-cmd.txt” コマンドリファレンス)
・以下のコマンドを実行
-Firehoseプラグインインストール
td-agent-gem install fluent-plugin-kinesis -v 2.1.0
-プラグインインストール確認
td-agent-gem list | grep plugin-kinesis
fluent-plugin-kinesis (2.1.0)
(4)EC2側の設定変更(Fluentd設定)
144
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
【①②③から続けてる場合】
利用Asset(asset4の”4-td-agent.conf1” Fluentd設定ファイル)
【①④から始めた場合】
利用Asset(asset4の”4-td-agent.conf2” Fluentd設定ファイル)
・/etc/td-agent/td-agent.confの中身を削除(viのコマンドの “:%d” などで削除)し、asset4に
ある4-td-agent.confをエディタで開き中身をコピーして貼り付ける。
(4)EC2側の設定変更(Fluentd設定)
145
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
【①④から始めた場合】
利用Asset(asset4の”4-cmd.txt” コマンドリファレンス)
・/etc/init.d/td-agentの先頭に以下の行を追加する(13行目)
export AWS_REGION="ap-northeast-1"
【両方】
利用Asset(asset4の”4-cmd.txt” コマンドリファレンス)
・/etc/init.d/td-agent restart
(4)EC2側の設定変更(Fluentd設定)
146
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
S3にデータが出力されていることを確認
※数分待つ
(4)EC2側の設定変更(Fluentd設定)
147
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Firehoseの画面で作成した”Delivery stream”の”minilake1”を選択し
“Monitoring”タブをクリック、表示に時間がかかるので次の手順に進む
(4)EC2側の設定変更(Fluentd設定)
148
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(5)IAM ロールにポリシー追加
作成済の”handson-minilake”のIAMロールに以下のポリシーを追加
 AWSGlueServiceRole
 AmazonS3ReadOnlyAccess
AWSマネージメントコンソールから”IAM”を選択し、[ロール]をクリック
[handson-minilake]のロール名をクリック
149
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(5)IAM ロールにポリシー追加
[ポリシーのアタッチ]をクリック
150
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(5)IAM ロールにポリシー追加
検索などを使いながら以下の2つのポリシーを探してアタッチする
 AWSGlueServiceRole
 AmazonS3ReadOnlyAccess
151
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
”信頼関係”タブをクリックし、[信頼関係の編集]ボタンをクリック
(5)Glue Crawler用にIAMロール修正
152
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
以下の画面で、”Service”: “ec2.amazonaws.com”の箇所にglueを追記する
※次ページ参照
(5)Glue Crawler用にIAMロール修正
153
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
[]でくくり、カンマで区切り、“glue.amazonaws.com”を追記する
[信頼ポリシーの更新]をクリック
(5)Glue Crawler用にIAMロール修正
154
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWSマネージメントコンソールで”Glue”を選択。
”クローラ”をクリック、[クローラの追加]をクリックする
(6)Glue Crawlerを使ってスキーマを自動作成
155
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“クローラの名前”に”minilake-in1”と入力し、[次へ]をクリック
(6)Glue Crawlerを使ってスキーマを自動作成
156
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“インクルードパス”に”作成した”S3バケット名/minilake-in1”を入力し
[次へ]をクリック。次も[次へ]をクリック
(6)Glue Crawlerを使ってスキーマを自動作成
157
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“既存のIAMロールを選択”にチェックを入れ、作成したロール”handson-minilake”を選択し、
[次へ]をクリック。次の画面も”オンデマンドで実行”のままにし、[次へ]をクリック
(6)Glue Crawlerを使ってスキーマを自動作成
158
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“データベース”の[データベースの追加]をクリックし、ポップアップした画面で
”データベース名”に“minilake”と入力し、[作成]をクリックする
(6)Glue Crawlerを使ってスキーマを自動作成
159
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
[次へ]をクリック。次のページで[完了]をクリックする
(6)Glue Crawlerを使ってスキーマを自動作成
160
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
作成したクローラーの”minilake-in1”にチェックを入れ、[クローラの実行]をクリックする
Statusが”Starting”になり、数分待つ。Statusが再度”Ready”に戻ったら左メニューの
”テーブル”をクリック
(6)Glue Crawlerを使ってスキーマを自動作成
161
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
以下の”minilake_in”のテーブルが作成されていることを確認し、
テーブル名の箇所をクリックしスキーマ定義を確認する
(6)Glue Crawlerを使ってスキーマを自動作成
162
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWSマネージメントコンソールで”Athena”を選択し
データベースを”minilake”を選び、テーブルを先程作った”minilake_in1”を選び、
テーブル名の右端の”点マーク”をクリックし”テーブルのプレビュー”をクリックする
(7)Athenaでクエリ実行
※過去にAthenaを利用したことがあ
る場合、データカタログをGlueのもの
を使用するようアップデートが必要に
なります。画面上に案内が表示されま
すので、クリックして移行を行ってくだ
さい。
163
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
クエリ結果が下部に表示されることを確認。
(7)Athenaでクエリ実行
164
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SELECT * の結果
実行時間:1.71s、スキャンデータ量:93.08KB
(7)Athenaでクエリ実行
165
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Whereを付けた場合の結果
実行時間:2.66s、スキャンデータ量:195.61KB
(7)Athenaでクエリ実行
好きなようにさわってみてください。
Enjoy Athena!
166
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SELECT * の結果
実行時間:4.39s、スキャンデータ量:6.07MB
(参考)Athenaでクエリ実行
しばらく時間が経って
データが溜まった状態
167
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Whereを付けた場合の結果
実行時間:2.66s、スキャンデータ量:195.61KB
(参考)Athenaでクエリ実行
しばらく時間が経って
データが溜まった状態
168
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Select * の場合
Whereを付けた場合の結果
(参考)Athenaでクエリ実行
実行時間:4.39s、スキャンデータ量:6.07MB
実行時間:2.66s、スキャンデータ量:195.6KB
Athenaはスキャンしたデータ量による課金、スキャン量がすくなければコストも低く抑えられ
さらにスキャン量が少なければパフォーマンス向上にもなる
しばらく時間が経って
データが溜まった状態
169
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(参考)Athenaでクエリ実行
https://aws.amazon.com/jp/blogs/news/top-10-performance-tuning-tips-for-amazon-athena/
読み取る量を減らす工夫でよく使われるのがパーティション、圧縮、カラムナフォーマット
170
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWSマネージメントコンソールから”QuickSight”を選択し、QuickSightを初めて使う方は
サインアップがまだされていないので以下の画面が出ます。”Sign up for QuickSight”を
クリックします
(8)QuickSight
171
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“Create your QuickSight account”で
“Standard”を選び、[Continue]をクリック
(8)QuickSight
1GBまでは無料利用枠ですが、
無料利用期間が終わってる場合
は、1ヶ月単位で$12かかるので
費用気になる場合はQuickSight
の部分は飛ばしても構いません
172
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“QuickSight account name”に名前
“Notification email address”にメール
アドレス
“QuickSight capacity region”を
Asia Pacific(Tokyo)を選択
[Finish]をクリック
(8)QuickSight
173
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
[Go to Amazon QuickSight]をクリックし、初回ログイン時のみ表示されるダイアログを消
去する。その後、右上のユーザー名をクリックし、“Manage QuickSight”をクリック
(8)QuickSight
※この作業はバージニアリージョンで行う必要があります
174
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“Account setting”をクリック
“Edit AWS permissions”をクリック
"Amazon Athena"にチェックを入れる
"Amazon S3"の[Choose S3 buckets]をクリック
"20180315-handson-minilake-ueharaxx"にチェックを入れ、[Select buckets]をクリック
[Apply]をクリック
左上のQuickSightのロゴをクリック
(8)QuickSight
175
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
リージョンを”Asia Pacific (Tokyo)”に戻す
(8)QuickSight
[New analysis]をクリックする
176
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
[New data set]をクリック
(8)QuickSight
177
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“Athena”をクリック、ポップアップ画面で”Data source name”に”minilake1”と入力し、
“Validate connection”をクリックし、成功したら[Create data source]をクリック
(8)QuickSight
178
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“Database”を”minilake”、Tablesを”minilake-in1”を選び、[Select]をクリックし、
“Finish data set creation”の画面で[Visualize]をクリック
(8)QuickSight
179
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SPICEを選び、“Import Complete”の画面で準備完了
"Fields list"や"Visual types"を適当に選び、データが可視化されていることを確認
(8)QuickSight 好きなようにさわってみてください。
Enjoy QuickSight!
180
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
④【まとめ】
AthenaS3KinesisDataFirehose
ストリーミングデータを直接データストアに永続化し、
長期間の保存を可能にした上で、アドホックな分析・可視化を行う
基盤ができました。
181
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
④【もっと活用】
Kinesis Data FirehoseはS3のみではなくRedshift、AmazonES、Splunkにもストリーミング
用のプログラムを書く必要なく直接ストリームデータ出力が可能。
S3KinesisDataFirehose
Amazon
Redshift
AmazonES
必要な要件に合わせたパイプライン形成ができる
182
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
⑥サーバーレスでデータのETL処理
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
⑥サーバーレスでデータのETL処理
AthenaS3KinesisDataFirehose Glue S3
Glueを使ってデータの加工処理をサーバーレスで行います
 ファイルフォーマットを”parquet”に変更
 ファイルをパーティショニングした配置
184
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
⑥サーバーレスでデータのETL処理
AthenaS3KinesisDataFirehose Glue S3
データ
永続化
モニタリングデータ
永続化
Glueを使ってデータの加工処理をサーバーレスで行います
 ファイルフォーマットを”parquet”に変更
 ファイルをパーティショニングした配置
185
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(1)IAM ロール修正
186
【④を実施しなかった場合】
(1)を実施してください。
④を実施した場合は(1)は飛ばして(2)から実施してください。
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(1)IAM ロールにポリシー追加
作成済の”handson-minilake”のIAMロールに以下のポリシーを追加
 AWSGlueServiceRole
 AmazonS3ReadOnlyAccess
AWSマネージメントコンソールから”IAM”を選択し、[ロール]をクリック
[handson-minilake]のロール名をクリック
187
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(1)IAM ロールにポリシー追加
[ポリシーのアタッチ]をクリック
188
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(1)IAM ロールにポリシー追加
検索などを使いながら以下の2つのポリシーを探してアタッチする
 AWSGlueServiceRole
 AmazonS3ReadOnlyAccess
189
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
”信頼関係”タブをクリックし、[信頼関係の編集]ボタンをクリック
(1)Glue Crawler用にIAMロール修正
190
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
以下の画面で、”Service”: “ec2.amazonaws.com”の箇所にglueを追記する
※次ページ参照
(1)Glue Crawler用にIAMロール修正
191
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
[]でくくり、カンマで区切り、“glue.amazonaws.com”を追記する
[信頼ポリシーの更新]をクリック
(1)Glue Crawler用にIAMロール修正
192
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)IAM ロール修正
AWSマネージメントコンソールから”IAM”を選択し、”ロール”をクリック
“handson-minilake”ロールをクリックし、[ポリシーのアタッチ]をクリック
193
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(2)IAM ロールにポリシー追加
検索などを使いながら以下のポリシーを探してアタッチする
 AmazonS3FullAccess
194
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(3)S3に出力先のフォルダ作成
AWSマネージメントコンソールから”S3”を選択し、今回作成したバケットを選択。
[+フォルダ作成]をクリックし、フォルダ名に”minilake-out1”と入力し、[保存]をクリック
195
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)GlueでETLジョブ作成と実行
AWSマネージメントコンソールから”Glue”を選択。
”ジョブ”をクリックし、[ジョブの追加]をクリック。
196
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)GlueでETLジョブ作成と実行
“名前”に”minilake1”
”IAMロール”に”handson-minilake”
上記入力
“詳細プロパティ”をクリック
“スクリプトライブラリおよびジョブパラメータ”
をクリック
197
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“Job metrics”を”有効化”
※リソースのモニタリングが可能になります
“ジョブ実行あたりの同時DPU”を”2”を
入力し、画面下の[次へ]をクリック
※DPUはGlueの処理能力でデフォルトは10
1DPU = 4vCPU,16GBメモリ
(4)GlueでETLジョブ作成と実行
198
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)GlueでETLジョブ作成と実行
“データソースの選択”で”minilake_in”にチェックを入れ、[次へ]をクリック
199
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)GlueでETLジョブ作成と実行
・“データターゲットの選択”で
・“データターゲットでテーブルを作成する”
にチェック
・“データストア”を”Amazon S3”
・“フォーマット”を“Parquet”
・“ターゲットパス”を
” s3://20180315-handson-minilake-ueha
raxx/minilake-out1”を選択
[次へ]をクリック
200
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)GlueでETLジョブ作成と実行
ここで不要なカラムを排除したり、データ型の変更を行えます。今回はこのまま[次へ]をクリック
次のページで [ジョブを保存してスクリプトを修正する]をクリック
201
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)GlueでETLジョブ作成と実行
[ジョブの実行]をクリックし、ポップアップ画面で[ジョブの実行]をクリックします
202
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(参考)GlueでETLジョブ作成と実行
DAG
SCRIPT
LOG
203203
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)GlueでETLジョブ作成と実行
AWSメニューからGlueをクリックしジョブをクリックし今回のジョブにチェックを入れる
10分程かかる場合もありますが、問題がなければ以下のように”実行ステータス”が
”Succeeded”となります。
※ 時間があれば“Metrics”タブでリソースモニタリングも確認してください。
表示まで少し時間かかります
204
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)GlueでETLジョブ作成と実行
“View additional metrics”をクリックすると詳細が見れますが、今回は値が小さすぎて
見づらいと思います。
205
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(4)GlueでETLジョブ作成と実行
S3の”20180315-handson-minilake-ueharaxx/minilake-out1/”に
ファイルが出力されていること
206
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(5)Glueクローラーを作成と実行
Glueで出力データ用のクローラーを作る
”クローラ”をクリックし、[クローラの追加]をクリック
207
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(5)Glueクローラーを作成と実行
“クローラの名前”に”minilake-out1”を入力し、[次へ]をクリック
208
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(5)Glueクローラーを作成と実行
“インクルードパス”に“s3://20180315-handson-minilake-ueharaxx/minilake-out1”
[次へ]をクリック
次もそのまま[次へ]をクリック
次に”既存のIAMロールを選択”をクリックし IAM ロールを”handson-minilake”を選び
[次へ]をクリック
次もそのまま[次へ]をクリック
209
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(5)Glueクローラーを作成と実行
“データベース”に”minilake”を選び 、
[次へ]をクリック。次のページで [完了]をクリック
210
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(5)Glueクローラーを作成と実行
“minilake-out1”にチェックを入れ、[クローラの実行]をクリックし
クローラーを実行する
211
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(5)Glueクローラーを作成と実行
左メニューの”テーブル”をクリックし、テーブル名“minilake_out1”をクリックし
スキーマ情報を確認する
212
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(6)Athenaでクエリ比較
SELECT count(user) FROM "minilake"."minilake_in1" where user='uchida'
and timestamp<='2018-02-19 21%' AND timestamp>='2018-02-18 12%';
以下のクエリを入力データと出力データに対して行う
 入力データ:CSV形式で日付でパーティション
 出力データ:parquet形式
※ uchidaさんをカウントしている
本日のログが出た時間が全て入
る様に指定してください。
213
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(6)Athenaでクエリ比較
SELECT count(user) FROM "minilake"."minilake_in1" where user='uchida'
and timestamp<='2018-02-19 21%' AND timestamp>='2018-02-18 12%';
“Run time”:6.71s
“Data scanned”:6.72MB
入力データのCSV形式をクエリ
しばらく時間が経って
データが溜まった状態
214
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(6)Athenaでクエリ比較
SELECT count(user) FROM "minilake"."minilake_out1" where user='uchida'
and timestamp<='2018-02-19 21%' AND timestamp>='2018-02-18 12%';
“Run time”:8.63s
“Data scanned”:84.25KB
出力データのparquet形式をクエリ
しばらく時間が経って
データが溜まった状態
215
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(6)Athenaでクエリ比較
8.63s 84.25KB
(1)CSVパーティション(日付) 6.71s 6.72MB
(2)parquet
Runtime Data scanned
不要なカラムを読まない分スキャ
ン容量が少ない
しばらく時間が経って
データが溜まった状態
216
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(6)Athenaでクエリ比較
2018-handson-
minilake-xxx
minilake-in1 2018 02 18 01
02
03
19 01
02
(1)CSVパーティション
(日付)
(2)parquet
year month day hourS3内のフォルダ構造
ここをパーティションと呼ぶ
単なるフォルダ構造
217
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
2018-handson-
minilake-xxx
minilake-in1
(6)Athenaでクエリ比較
2018 02 18 01
02
03
19 01
02
(1)CSVパーティション
(日付)
(2)parquet
year month day hourS3内のフォルダ構造
ここをパーティションと呼ぶ
単なるフォルダ構造
2018年02月18日01時のデータを検索する時
緑の矢印の部分だけが読まれて不要なIOが発生せず
パフォーマンスの向上とスキャン量が減ることでコストも低く抑えられる
218
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
2018-handson-
minilake-xxx
minilake-in1
(6)Athenaでクエリ比較
2018 02 18 01
02
03
19 01
02
(1)CSVパーティション
(日付)
(2)parquet
year month day hourS3内のフォルダ構造
ここをパーティションと呼ぶ
単なるフォルダ構造
uchidaさんで検索すると全件スキャンとなる
userでパーティションが切られていないから
219
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(6)Athenaでクエリ比較
2018-handson-
minilake-xxx
S3
minilake-out1
(1)CSVパーティション(日付)
(2)parquet
parquetは列指向フォーマットなので必要なカラムだけ読むが
uchidaさんで検索するとファイル自体は全件スキャンとなる
xxx1.parquet
xxx2.parquet
220
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
2018-handson-
minilake-xxx
parquetは列指向フォーマットなので必要なカラムだけ読むが
uchidaさんで検索するとファイル自体は全件スキャンとなる
(6)Athenaでクエリ比較
Minilake-out
(1)CSVパーティション(日付)
(2)parquet
xxx1.parquet
xxx2.parquet
S3
221
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(7)よくwhereする項目でパーティションを切る
パーティションの意義は頻繁にWhereされる範囲を分割してスキャン量を減らすこと
userでwhereするクエリが多いのであれば、userでパーティションを切ることで
不要なアクセスを減らせる。
222
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(8)S3に出力用フォルダ作成
S3で”minilake-out2”フォルダを作成
223
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(9)Glue ジョブ修正
“Glue”を開き、”ジョブ”から”minilake1”ジョブにチェックを入れ、[アクション]から
”スクリプトの編集”をクリック
224
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(9)Glue ジョブ修正
右側のスクリプト編集箇所で”applymapping1”と”datasink4”の2箇所編集を加える
225
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(9)Glue ジョブ修正
既存の”applymapping1”と”datasink4”の行をコメントアウトし、目印に###1の行を入れ
それぞれの行の下にコマンドリファレンスのコードをコピペする
※コードは入り切らないのでリファレンス参照ください。
#datasink4 = glueContext.write_dynamic_frame.from_options(frame = dropnullfields3, connection_type = "s3", con
###1
datasink4 = glueContext.write_dynamic_frame.from_options(frame = dropnullfields3, connection_type = "s3", conn
#applymapping1 = ApplyMapping.apply(frame = datasource0, mappings = [("timestamp", "string", "timestamp", "st
###1
applymapping1 = ApplyMapping.apply(frame = datasource0, mappings = [("timestamp", "string", "timestamp", "stri
226
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(9)Glue ジョブ修正
利用Asset(asset6の”6-cmd.txt” コマンドリファレンス)
コピーした行に以下の修正を加え[Save]。
 datasink4には以下を追記
connection_options = {"path": "s3://20180315-handson-minilake-ueharaxx/minilake-out2", "partitionKeys":
["user","year", "month", "day","hour"]},format = "parquet")
 applymapping1には以下を追記
("partition_0", "string", "year", "string"), ("partition_1", "string", "month", "string"), ("partition_2", "string", "day",
"string"), ("partition_3", "string", "hour", "string")
Partition_0などはわかりずらいの
でapplymapping関数でyearや
monthに変換
Write_dynamic_frameの
partitionKeysオプションを使い
パーティション分割して出力指定
バケット名は、各自の命名に合わ
せて修正
227
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(9)Glue ジョブ修正
左上の[ジョブの実行]をクリック、ポップアップした画面で[ジョブの実行]をクリック
228
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWSマネージメントコンソールで”Glue”を選択。
”クローラ”をクリック、[クローラの追加]をクリックする
(10)Glue Crawlerを使ってスキーマを自動作成
229
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“クローラの名前”に”minilake-out2”と入力し、[次へ]をクリック
(10)Glue Crawlerを使ってスキーマを自動作成
230
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“インクルードパス”に“s3://20180315-handson-minilake-ueharaxx/minilake-out2
[次へ]をクリック。次のページも[次へ]をクリック
(10)Glue Crawlerを使ってスキーマを自動作成
231
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“既存のIAMロールを選択”にチェックを入れ、
作成したロールの”handson-minilake”を選択し、[次へ]をクリック
次の画面も”オンデマンドで実行”のままにし、[次へ]をクリック
(10)Glue Crawlerを使ってスキーマを自動作成
232
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“データベース”に”minilake”を選び、
[次へ]をクリック、次のページで [完了]をクリック
(10)Glue Crawlerを使ってスキーマを自動作成
233
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
作成したクローラーの”minilake-out2”にチェックを入れ、[クローラの実行]をクリックする
ステータスが”Starting”になり、数分待つ。ステータスが再度”Ready”に戻ったら左メニューの
”テーブル”をクリック
(10)Glue Crawlerを使ってスキーマを自動作成
234
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
“minilake_out2”のテーブルが作成されていることを確認し、
テーブル名の箇所をクリックしテーブル内容を確認する
(10)Glue Crawlerを使ってスキーマを自動作成
235
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(11)Athenaでクエリ比較
“Run time”:8.73s
“Data scanned”:19.57KB
出力のparquetパーティション形式
をクエリ
SELECT count(user) FROM "minilake"."minilake_out2" where user='uchida'
and timestamp<='2018-02-19 21%' AND timestamp>='2018-02-18 12%';
しばらく時間が経って
データが溜まった状態
236
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
uchida
(11)Athenaでクエリ比較
2018-handson-
minilake-xxx
minilake-in1 2018 02 18 01
02
03
19 01
02
(1)CSVパーティション(日付)
(2)parquet
year month day hourS3内のフォルダ構造
ここをパーティションと呼ぶ
単なるフォルダ構造
uchidaさんで検索するとuchida配下のディレクトリだけがスキャンされる
(3)Parquetパーティション(user)
user
kimura 2018 ・・
237
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
2018-handson-
minilake-xxx
minilake-in1 uchida
(11)Athenaでクエリ比較
2018 02 18 01
02
03
19 01
02
(1)CSVパーティション(日付)
(2)parquet
year month day hourS3内のフォルダ構造
ここをパーティションと呼ぶ
単なるフォルダ構造
uchidaさんで検索するとuchida配下のディレクトリだけがスキャンされる
(3)Parquetパーティション(user)
user
kimura 2018 ・・
238
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
2018-handson-
minilake-xxx
minilake-in1 uchida
(11)Athenaでクエリ比較
2018 02 18 01
02
03
19 01
02
(1)CSVパーティション(日付)
(2)parquet
year month day hourS3内のフォルダ構造
ここをパーティションと呼ぶ
単なるフォルダ構造
uchidaさんで検索するとuchida配下のディレクトリだけがスキャンされる
(3)Parquetパーティション(user)
user
kimura 2018 ・・
239
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(11)Athenaでクエリ比較
6.07s 1.39KB
(1)CSVパーティション(日付) 4.51s 93.11KB
(2)parquet
Runtime Data scanned
8.03s 0.12KB(3)parquetパーティション(user)
データがまだ少ないので
みなさんの結果もこのく
らいの値でしょうか?
それでもparquetパー
ティション形式のデータ
に対してスキャンしてる
容量が少ないことがわか
ります。
240
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(11)Athenaでクエリ比較
8.63s 84.25KB
6.71s 6.72MB
Runtime Data scanned
8.73s 19.57KB
この値は数時間経った状
態です。
数時間経つとこのくらいの
結果になります。
(1)CSVパーティション(日付)
(2)parquet
(3)parquetパーティション(user)
241
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(11)Athenaでクエリ比較
49.12s 84.25KB
18.54s 133.85MB
Runtime Data scanned
8.18s 19.57KB
CSVのままだと
2.5倍くらいの時間
全データスキャンし
てるのでコストも
かかる
スキャン量も時間も
先程と変わらない
20日経って133MBのデー
タだとこのくらいになります。
今回は数KBの小さいファイル
が多くなってるので時間がか
かっている。S3DistCPや
HadoopのMergeなどでまと
めることで速度改善する
これはたかが133MB、データ量が
さらに増えればこの差はより顕著
(1)CSVパーティション(日付)
(2)parquet
(3)parquetパーティション(user)
242
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(10)Athenaでクエリ比較
10.88s 84.25KB
(1)CSVパーティション 18.54s 133.85MB
(2)parquet
Runtime Data scanned
8.18s 19.57KB(3)parquetパーティション
CSVのままだと
2.5倍くらいの時間
全データスキャンし
てるのでコストも
かかる
スキャン量も時間も
先程と変わらない
20日経って133MBのデー
タだとこのくらいになります。
https://aws.amazon.com/jp/blogs/news/top-10-performance-tuning-tips-for-amazon-athena/243
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
⑥【まとめ】
AthenaS3KinesisDataFirehose Glue S3
以上でサーバーレスでのETL処理パイプラインができました。
行いたいクエリに対して最適なデータの形への変換処理
244
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
⑥【もっと活用】
今回Glueを使い、S3のデータを変換してS3出力しましたが、それ以外にも同じような変換
を行った出力をRedshiftやRDSやRDB on EC2に出力することも可能です。
またRDSやRedshiftやRDB on EC2を入力データにすることもできます。
Amazon
Redshift
ETL処理基板として様々なサービスに変換とロード可能
Glue
S3
Amazon
RDS
Amazon
Redshift
Amazon
RDS
S3
※Glueでは開発にApache Zeppelin Notebookを利用可能
Amazon
DynamoDB
New
245
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(オプション1)repartition()で小さいファイルを
まとめる
• repartition()を使って小さいたくさんあるファイルをマージしてクエリ結果時間の確認
Glueジョブコードの入力と出力を変更してジョブ実行
クローラーを新規作成しクローリング、作成されたテーブルでAthenaクエリ実行
246
・S3でフォルダ作成
”minilake-out3”
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(オプション1)repartition()で小さいファイルを
まとめる
既存の”datasink4”の行をコメントアウトし、目印に###2の行を入れ
行の下にコマンドリファレンスのコードをコピペする
※コードは入り切らないのでリファレンス参照ください。
#datasink4 = glueContext.write_dynamic_frame.from_options(frame = dropnullfields3, connection_type = "s3", con
###2
df = dropnullfields3.toDF()
df.repartition(4).write.mode("overwrite").parquet("s3://20180820-handson-minilake-ueharaxx/minilake-month-out1"
247
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
利用Asset(asset6の”6-cmd.txt” コマンドリファレンス)
コピーした行に以下の修正を加え[Save]して[実行]。
 datasink4には以下を追記
df.repartition(4).write.mode("overwrite").parquet("s3://20180820-handson-minilake-ueharaxx/minilake-out3",compre
 DataFrameに変換
df = dropnullfields3.toDF()
パーティション数が出力ファイル
数になる。任意の値を入れる
バケット名は、各自の命名に合わ
せて修正
(オプション1)repartition()で小さいファイルを
まとめる
248
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(オプション1)repartition()で小さいファイルを
まとめる
指定したパーティション数の4つのファイルが出力されている
249
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(オプション1)repartition()で小さいファイルを
まとめる
クローラーを作成しクローリングを実行しテーブルを作成。
Athenaでクエリを実行し、
parquetファイルが多数あったminilake_out1テーブルとの差を確認する
時間:2.45s
データ量:1.46KB
作成済のテーブル
minilake_out1
250
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(オプション1)repartition()で小さいファイルを
まとめる
クローラーを作成しクローリングを実行しテーブルを作成。
Athenaでクエリを実行し、
parquetファイルが多数あったminilake_out1テーブルとの差を確認する
時間:0.89s
データ量:1.52KB
作成したテーブル
minilake_out3
251
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(オプション2) S3 Select で parquetファイルを開く
252
S3の画面から、今回作成したparquet ファイルを表示します。対象ファイルにチェックを入れ
“アクション”->”S3 Select”をクリック
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(オプション2) S3 Select で parquetファイルを開く
253
“Parquet”にチェックを入れる
[ファイルプレビューの表示]をクリックする
Parquetファイル内の5件が表示されます。
[次へ]をクリック
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
(オプション2) S3 Select で parquetファイルを開く
254
SQLエディタで任意のクエリを実行してみてください。サンプルもあります。
従来簡単な確認のための表示が難しかったparquetファイルですが、このように簡単に確認できます。
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Glue関連情報
• https://qiita.com/pioho07/items/32f76a16cbf49f9f712f
Glue関連資料
255
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
あとかたずけ
この作業まで終えていない場合、継続して課金が発生いたしますので、
必ず行ってください。
256
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
あとかたずけ
⑥
1. Glue Job(ジョブ名:minilake1)
2. Crawlerの削除(クローラー名:minilake-in1、minilake-out1、minilake-out2)
3. Glue Tableの削除(テーブル名:minilake_out1、minilake_out2、minilake_month
_out1)
4. Glue Databaseの削除(データベース名:minilake)
257
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
あとかたずけ
⑤
1. QuickSightのVPC Connectionsを削除
2. QuickSightのUnsubscribe(バージニアリージョンで行う必要があります)
3. S3バケットの削除(バケット名: 20180315-handson-minilake-ueharaxx)
4. KinesisFirehoseの削除(ストリーム名:minilake1)
5. Redshiftの削除
6. Glue Tableの削除(テーブル名:ec2log_external)
7. Glue Databaseの削除(データベース名:spectrumdb)
8. Redshiftクラスターの削除
258
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
あとかたずけ
⑤ CloudFormationコンソールから、”handson-minilake-private-subnet”スタックを削除。
259
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
あとかたずけ
④
1. QuickSightのUnsubscribe(バージニアリージョンで行う必要があります)
QuickSightのアカウント名クリック->Account settings->”Unsubscribe”
2. S3バケットの削除(バケット名: 20180315-handson-minilake-ueharaxx)
3. KinesisFirehoseの削除(ストリーム名:minilake1)
4. Glue Crawlerの削除(クローラー名:minilake1)
5. Glue Tableの削除(テーブル名:minilake_in1、minilake_out1、ec2log_external)
6. Glue Databaseの削除(データベース名:minilake、spectrumdb)
260
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
あとかたずけ
③まで
1. Cloudwatch Logsの削除(ロググループ名以下)
• 東京リージョン
 /minilake_group
 /aws/lambda/LogsToElasticsearch_handson-minilake
 /aws/kinesisfirehose/minilake1
 /aws-glue/crawlers/の”minilake1”ストリーム
• /aws-glue/jobs/error、 /aws-glue/jobs/outputのストリームはジョブIDごとに
作成されます。Glueをいままで使っていなければロググループごとけしてください
もし既存のログに影響をあたえず今回のログだけ削除したい場合はおこえかけく
ださい
2. Lambdaの削除(Function名:LogsToElasticsearch-handson_minilake)
3. CloudwatchAlarm(アラーム名:minilake_errlog)
261
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
あとかたずけ
②まで
1. AmazonESの削除 (ドメイン名:handson-minilake)
2. CloudFormationでスタック削除(EC2やEIPの削除)
3. IAMロールの削除(ロール名:handson-minilake)
262
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
あとかたずけ
① CloudFormationコンソールから、”handson-minilake”スタックを削除。
263
©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
補足資料:AWSの技術リソース
Data Lake ハンズオン

Mais conteúdo relacionado

Mais procurados

20200617 AWS Black Belt Online Seminar Amazon Athena
20200617 AWS Black Belt Online Seminar Amazon Athena20200617 AWS Black Belt Online Seminar Amazon Athena
20200617 AWS Black Belt Online Seminar Amazon AthenaAmazon Web Services Japan
 
データ活用を加速するAWS分析サービスのご紹介
データ活用を加速するAWS分析サービスのご紹介データ活用を加速するAWS分析サービスのご紹介
データ活用を加速するAWS分析サービスのご紹介Amazon Web Services Japan
 
20190730 AWS Black Belt Online Seminar Amazon CloudFrontの概要
20190730 AWS Black Belt Online Seminar Amazon CloudFrontの概要20190730 AWS Black Belt Online Seminar Amazon CloudFrontの概要
20190730 AWS Black Belt Online Seminar Amazon CloudFrontの概要Amazon Web Services Japan
 
20200721 AWS Black Belt Online Seminar AWS App Mesh
20200721 AWS Black Belt Online Seminar AWS App Mesh20200721 AWS Black Belt Online Seminar AWS App Mesh
20200721 AWS Black Belt Online Seminar AWS App MeshAmazon Web Services Japan
 
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチAmazon Web Services Japan
 
20200623 AWS Black Belt Online Seminar Amazon Elasticsearch Service
20200623 AWS Black Belt Online Seminar Amazon Elasticsearch Service20200623 AWS Black Belt Online Seminar Amazon Elasticsearch Service
20200623 AWS Black Belt Online Seminar Amazon Elasticsearch ServiceAmazon Web Services Japan
 
20190320 AWS Black Belt Online Seminar Amazon EBS
20190320 AWS Black Belt Online Seminar Amazon EBS20190320 AWS Black Belt Online Seminar Amazon EBS
20190320 AWS Black Belt Online Seminar Amazon EBSAmazon Web Services Japan
 
AWS Black Belt Online Seminar 2017 Amazon Kinesis
AWS Black Belt Online Seminar 2017 Amazon KinesisAWS Black Belt Online Seminar 2017 Amazon Kinesis
AWS Black Belt Online Seminar 2017 Amazon KinesisAmazon Web Services Japan
 
202110 AWS Black Belt Online Seminar AWS Site-to-Site VPN
202110 AWS Black Belt Online Seminar AWS Site-to-Site VPN202110 AWS Black Belt Online Seminar AWS Site-to-Site VPN
202110 AWS Black Belt Online Seminar AWS Site-to-Site VPNAmazon Web Services Japan
 
20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session
20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session
20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic SessionAmazon Web Services Japan
 
20180425 AWS Black Belt Online Seminar Amazon Relational Database Service (Am...
20180425 AWS Black Belt Online Seminar Amazon Relational Database Service (Am...20180425 AWS Black Belt Online Seminar Amazon Relational Database Service (Am...
20180425 AWS Black Belt Online Seminar Amazon Relational Database Service (Am...Amazon Web Services Japan
 
20190814 AWS Black Belt Online Seminar AWS Serverless Application Model
20190814 AWS Black Belt Online Seminar AWS Serverless Application Model  20190814 AWS Black Belt Online Seminar AWS Serverless Application Model
20190814 AWS Black Belt Online Seminar AWS Serverless Application Model Amazon Web Services Japan
 
Kinesis + Elasticsearchでつくるさいきょうのログ分析基盤
Kinesis + Elasticsearchでつくるさいきょうのログ分析基盤Kinesis + Elasticsearchでつくるさいきょうのログ分析基盤
Kinesis + Elasticsearchでつくるさいきょうのログ分析基盤Amazon Web Services Japan
 
20190806 AWS Black Belt Online Seminar AWS Glue
20190806 AWS Black Belt Online Seminar AWS Glue20190806 AWS Black Belt Online Seminar AWS Glue
20190806 AWS Black Belt Online Seminar AWS GlueAmazon Web Services Japan
 
20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用
20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用
20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用Amazon Web Services Japan
 
20180509 AWS Black Belt Online Seminar Amazon GuardDuty
20180509 AWS Black Belt Online Seminar Amazon GuardDuty20180509 AWS Black Belt Online Seminar Amazon GuardDuty
20180509 AWS Black Belt Online Seminar Amazon GuardDutyAmazon Web Services Japan
 
20191002 AWS Black Belt Online Seminar Amazon EC2 Auto Scaling and AWS Auto S...
20191002 AWS Black Belt Online Seminar Amazon EC2 Auto Scaling and AWS Auto S...20191002 AWS Black Belt Online Seminar Amazon EC2 Auto Scaling and AWS Auto S...
20191002 AWS Black Belt Online Seminar Amazon EC2 Auto Scaling and AWS Auto S...Amazon Web Services Japan
 
20200630 AWS Black Belt Online Seminar Amazon Cognito
20200630 AWS Black Belt Online Seminar Amazon Cognito20200630 AWS Black Belt Online Seminar Amazon Cognito
20200630 AWS Black Belt Online Seminar Amazon CognitoAmazon Web Services Japan
 
AWS Black Belt Techシリーズ Elastic Load Balancing (ELB)
AWS Black Belt Techシリーズ  Elastic Load Balancing (ELB)AWS Black Belt Techシリーズ  Elastic Load Balancing (ELB)
AWS Black Belt Techシリーズ Elastic Load Balancing (ELB)Amazon Web Services Japan
 
20190604 AWS Black Belt Online Seminar Amazon Simple Notification Service (SNS)
20190604 AWS Black Belt Online Seminar Amazon Simple Notification Service (SNS)20190604 AWS Black Belt Online Seminar Amazon Simple Notification Service (SNS)
20190604 AWS Black Belt Online Seminar Amazon Simple Notification Service (SNS)Amazon Web Services Japan
 

Mais procurados (20)

20200617 AWS Black Belt Online Seminar Amazon Athena
20200617 AWS Black Belt Online Seminar Amazon Athena20200617 AWS Black Belt Online Seminar Amazon Athena
20200617 AWS Black Belt Online Seminar Amazon Athena
 
データ活用を加速するAWS分析サービスのご紹介
データ活用を加速するAWS分析サービスのご紹介データ活用を加速するAWS分析サービスのご紹介
データ活用を加速するAWS分析サービスのご紹介
 
20190730 AWS Black Belt Online Seminar Amazon CloudFrontの概要
20190730 AWS Black Belt Online Seminar Amazon CloudFrontの概要20190730 AWS Black Belt Online Seminar Amazon CloudFrontの概要
20190730 AWS Black Belt Online Seminar Amazon CloudFrontの概要
 
20200721 AWS Black Belt Online Seminar AWS App Mesh
20200721 AWS Black Belt Online Seminar AWS App Mesh20200721 AWS Black Belt Online Seminar AWS App Mesh
20200721 AWS Black Belt Online Seminar AWS App Mesh
 
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
 
20200623 AWS Black Belt Online Seminar Amazon Elasticsearch Service
20200623 AWS Black Belt Online Seminar Amazon Elasticsearch Service20200623 AWS Black Belt Online Seminar Amazon Elasticsearch Service
20200623 AWS Black Belt Online Seminar Amazon Elasticsearch Service
 
20190320 AWS Black Belt Online Seminar Amazon EBS
20190320 AWS Black Belt Online Seminar Amazon EBS20190320 AWS Black Belt Online Seminar Amazon EBS
20190320 AWS Black Belt Online Seminar Amazon EBS
 
AWS Black Belt Online Seminar 2017 Amazon Kinesis
AWS Black Belt Online Seminar 2017 Amazon KinesisAWS Black Belt Online Seminar 2017 Amazon Kinesis
AWS Black Belt Online Seminar 2017 Amazon Kinesis
 
202110 AWS Black Belt Online Seminar AWS Site-to-Site VPN
202110 AWS Black Belt Online Seminar AWS Site-to-Site VPN202110 AWS Black Belt Online Seminar AWS Site-to-Site VPN
202110 AWS Black Belt Online Seminar AWS Site-to-Site VPN
 
20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session
20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session
20190206 AWS Black Belt Online Seminar Amazon SageMaker Basic Session
 
20180425 AWS Black Belt Online Seminar Amazon Relational Database Service (Am...
20180425 AWS Black Belt Online Seminar Amazon Relational Database Service (Am...20180425 AWS Black Belt Online Seminar Amazon Relational Database Service (Am...
20180425 AWS Black Belt Online Seminar Amazon Relational Database Service (Am...
 
20190814 AWS Black Belt Online Seminar AWS Serverless Application Model
20190814 AWS Black Belt Online Seminar AWS Serverless Application Model  20190814 AWS Black Belt Online Seminar AWS Serverless Application Model
20190814 AWS Black Belt Online Seminar AWS Serverless Application Model
 
Kinesis + Elasticsearchでつくるさいきょうのログ分析基盤
Kinesis + Elasticsearchでつくるさいきょうのログ分析基盤Kinesis + Elasticsearchでつくるさいきょうのログ分析基盤
Kinesis + Elasticsearchでつくるさいきょうのログ分析基盤
 
20190806 AWS Black Belt Online Seminar AWS Glue
20190806 AWS Black Belt Online Seminar AWS Glue20190806 AWS Black Belt Online Seminar AWS Glue
20190806 AWS Black Belt Online Seminar AWS Glue
 
20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用
20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用
20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用
 
20180509 AWS Black Belt Online Seminar Amazon GuardDuty
20180509 AWS Black Belt Online Seminar Amazon GuardDuty20180509 AWS Black Belt Online Seminar Amazon GuardDuty
20180509 AWS Black Belt Online Seminar Amazon GuardDuty
 
20191002 AWS Black Belt Online Seminar Amazon EC2 Auto Scaling and AWS Auto S...
20191002 AWS Black Belt Online Seminar Amazon EC2 Auto Scaling and AWS Auto S...20191002 AWS Black Belt Online Seminar Amazon EC2 Auto Scaling and AWS Auto S...
20191002 AWS Black Belt Online Seminar Amazon EC2 Auto Scaling and AWS Auto S...
 
20200630 AWS Black Belt Online Seminar Amazon Cognito
20200630 AWS Black Belt Online Seminar Amazon Cognito20200630 AWS Black Belt Online Seminar Amazon Cognito
20200630 AWS Black Belt Online Seminar Amazon Cognito
 
AWS Black Belt Techシリーズ Elastic Load Balancing (ELB)
AWS Black Belt Techシリーズ  Elastic Load Balancing (ELB)AWS Black Belt Techシリーズ  Elastic Load Balancing (ELB)
AWS Black Belt Techシリーズ Elastic Load Balancing (ELB)
 
20190604 AWS Black Belt Online Seminar Amazon Simple Notification Service (SNS)
20190604 AWS Black Belt Online Seminar Amazon Simple Notification Service (SNS)20190604 AWS Black Belt Online Seminar Amazon Simple Notification Service (SNS)
20190604 AWS Black Belt Online Seminar Amazon Simple Notification Service (SNS)
 

Semelhante a Data Lake ハンズオン

ServerlessConf Tokyo2018 サーバーレスなシステムのがんばらない運用監視
ServerlessConf Tokyo2018 サーバーレスなシステムのがんばらない運用監視ServerlessConf Tokyo2018 サーバーレスなシステムのがんばらない運用監視
ServerlessConf Tokyo2018 サーバーレスなシステムのがんばらない運用監視Takanori Suzuki
 
Introduction to New CloudWatch Agent
Introduction to New CloudWatch AgentIntroduction to New CloudWatch Agent
Introduction to New CloudWatch AgentNoritaka Sekiyama
 
Hinemosによるハイブリッドクラウド運用管理の最新情報
Hinemosによるハイブリッドクラウド運用管理の最新情報Hinemosによるハイブリッドクラウド運用管理の最新情報
Hinemosによるハイブリッドクラウド運用管理の最新情報Hinemos
 
初心者向けWebinar AWSでDRを構築しよう
初心者向けWebinar AWSでDRを構築しよう初心者向けWebinar AWSでDRを構築しよう
初心者向けWebinar AWSでDRを構築しようAmazon Web Services Japan
 
AWS IoT SiteWise のご紹介 (AWS IoT Deep Dive #5)
AWS IoT SiteWise のご紹介 (AWS IoT Deep Dive #5)AWS IoT SiteWise のご紹介 (AWS IoT Deep Dive #5)
AWS IoT SiteWise のご紹介 (AWS IoT Deep Dive #5)Amazon Web Services Japan
 
Security Operations and Automation on AWS
Security Operations and Automation on AWSSecurity Operations and Automation on AWS
Security Operations and Automation on AWSNoritaka Sekiyama
 
多要素認証による Amazon WorkSpaces の利用
多要素認証による Amazon WorkSpaces の利用多要素認証による Amazon WorkSpaces の利用
多要素認証による Amazon WorkSpaces の利用Amazon Web Services Japan
 
開発者におくるサーバーレスモニタリング
開発者におくるサーバーレスモニタリング開発者におくるサーバーレスモニタリング
開発者におくるサーバーレスモニタリングAmazon Web Services Japan
 
AWS監視ソフトウェアの決定版 Hinemosが実現するAWS統合監視の全て
AWS監視ソフトウェアの決定版 Hinemosが実現するAWS統合監視の全てAWS監視ソフトウェアの決定版 Hinemosが実現するAWS統合監視の全て
AWS監視ソフトウェアの決定版 Hinemosが実現するAWS統合監視の全てHinemos
 
Amazon ElastiCache - AWSマイスターシリーズ
Amazon ElastiCache - AWSマイスターシリーズAmazon ElastiCache - AWSマイスターシリーズ
Amazon ElastiCache - AWSマイスターシリーズSORACOM, INC
 
B 8スポンサー講演資料 osnexus steven umbehocker (アファーム・ビジネスパートナーズ株)
B 8スポンサー講演資料 osnexus steven umbehocker (アファーム・ビジネスパートナーズ株)B 8スポンサー講演資料 osnexus steven umbehocker (アファーム・ビジネスパートナーズ株)
B 8スポンサー講演資料 osnexus steven umbehocker (アファーム・ビジネスパートナーズ株)softlayerjp
 
B 8スポンサー講演資料 osnexus steven umbehocker (アファーム・ビジネスパートナーズ株)
B 8スポンサー講演資料 osnexus steven umbehocker (アファーム・ビジネスパートナーズ株)B 8スポンサー講演資料 osnexus steven umbehocker (アファーム・ビジネスパートナーズ株)
B 8スポンサー講演資料 osnexus steven umbehocker (アファーム・ビジネスパートナーズ株)chenree3
 
Amazon Kinesis Familyを活用したストリームデータ処理
Amazon Kinesis Familyを活用したストリームデータ処理Amazon Kinesis Familyを活用したストリームデータ処理
Amazon Kinesis Familyを活用したストリームデータ処理Amazon Web Services Japan
 
AWS Black Belt Techシリーズ Amazon ElastiCache
AWS Black Belt Techシリーズ Amazon ElastiCacheAWS Black Belt Techシリーズ Amazon ElastiCache
AWS Black Belt Techシリーズ Amazon ElastiCacheAmazon Web Services Japan
 
20180619 AWS Black Belt Online Seminar データレイク入門: AWSで様々な規模のデータレイクを分析する効率的な方法
20180619 AWS Black Belt Online Seminar データレイク入門: AWSで様々な規模のデータレイクを分析する効率的な方法20180619 AWS Black Belt Online Seminar データレイク入門: AWSで様々な規模のデータレイクを分析する効率的な方法
20180619 AWS Black Belt Online Seminar データレイク入門: AWSで様々な規模のデータレイクを分析する効率的な方法Amazon Web Services Japan
 
20180704 AWS Black Belt Online Seminar Amazon Elastic File System (Amazon EFS...
20180704 AWS Black Belt Online Seminar Amazon Elastic File System (Amazon EFS...20180704 AWS Black Belt Online Seminar Amazon Elastic File System (Amazon EFS...
20180704 AWS Black Belt Online Seminar Amazon Elastic File System (Amazon EFS...Amazon Web Services Japan
 

Semelhante a Data Lake ハンズオン (20)

ServerlessConf Tokyo2018 サーバーレスなシステムのがんばらない運用監視
ServerlessConf Tokyo2018 サーバーレスなシステムのがんばらない運用監視ServerlessConf Tokyo2018 サーバーレスなシステムのがんばらない運用監視
ServerlessConf Tokyo2018 サーバーレスなシステムのがんばらない運用監視
 
Serverless analytics on aws
Serverless analytics on awsServerless analytics on aws
Serverless analytics on aws
 
Introduction to New CloudWatch Agent
Introduction to New CloudWatch AgentIntroduction to New CloudWatch Agent
Introduction to New CloudWatch Agent
 
Hinemosによるハイブリッドクラウド運用管理の最新情報
Hinemosによるハイブリッドクラウド運用管理の最新情報Hinemosによるハイブリッドクラウド運用管理の最新情報
Hinemosによるハイブリッドクラウド運用管理の最新情報
 
初心者向けWebinar AWSでDRを構築しよう
初心者向けWebinar AWSでDRを構築しよう初心者向けWebinar AWSでDRを構築しよう
初心者向けWebinar AWSでDRを構築しよう
 
AWS IoT SiteWise のご紹介 (AWS IoT Deep Dive #5)
AWS IoT SiteWise のご紹介 (AWS IoT Deep Dive #5)AWS IoT SiteWise のご紹介 (AWS IoT Deep Dive #5)
AWS IoT SiteWise のご紹介 (AWS IoT Deep Dive #5)
 
Security Operations and Automation on AWS
Security Operations and Automation on AWSSecurity Operations and Automation on AWS
Security Operations and Automation on AWS
 
多要素認証による Amazon WorkSpaces の利用
多要素認証による Amazon WorkSpaces の利用多要素認証による Amazon WorkSpaces の利用
多要素認証による Amazon WorkSpaces の利用
 
開発者におくるサーバーレスモニタリング
開発者におくるサーバーレスモニタリング開発者におくるサーバーレスモニタリング
開発者におくるサーバーレスモニタリング
 
AWS監視ソフトウェアの決定版 Hinemosが実現するAWS統合監視の全て
AWS監視ソフトウェアの決定版 Hinemosが実現するAWS統合監視の全てAWS監視ソフトウェアの決定版 Hinemosが実現するAWS統合監視の全て
AWS監視ソフトウェアの決定版 Hinemosが実現するAWS統合監視の全て
 
20120117 13 meister-elasti_cache-public
20120117 13 meister-elasti_cache-public20120117 13 meister-elasti_cache-public
20120117 13 meister-elasti_cache-public
 
Amazon ElastiCache - AWSマイスターシリーズ
Amazon ElastiCache - AWSマイスターシリーズAmazon ElastiCache - AWSマイスターシリーズ
Amazon ElastiCache - AWSマイスターシリーズ
 
B 8スポンサー講演資料 osnexus steven umbehocker (アファーム・ビジネスパートナーズ株)
B 8スポンサー講演資料 osnexus steven umbehocker (アファーム・ビジネスパートナーズ株)B 8スポンサー講演資料 osnexus steven umbehocker (アファーム・ビジネスパートナーズ株)
B 8スポンサー講演資料 osnexus steven umbehocker (アファーム・ビジネスパートナーズ株)
 
B 8スポンサー講演資料 osnexus steven umbehocker (アファーム・ビジネスパートナーズ株)
B 8スポンサー講演資料 osnexus steven umbehocker (アファーム・ビジネスパートナーズ株)B 8スポンサー講演資料 osnexus steven umbehocker (アファーム・ビジネスパートナーズ株)
B 8スポンサー講演資料 osnexus steven umbehocker (アファーム・ビジネスパートナーズ株)
 
Amazon Kinesis Familyを活用したストリームデータ処理
Amazon Kinesis Familyを活用したストリームデータ処理Amazon Kinesis Familyを活用したストリームデータ処理
Amazon Kinesis Familyを活用したストリームデータ処理
 
AWS Black Belt Techシリーズ Amazon ElastiCache
AWS Black Belt Techシリーズ Amazon ElastiCacheAWS Black Belt Techシリーズ Amazon ElastiCache
AWS Black Belt Techシリーズ Amazon ElastiCache
 
20180619 AWS Black Belt Online Seminar データレイク入門: AWSで様々な規模のデータレイクを分析する効率的な方法
20180619 AWS Black Belt Online Seminar データレイク入門: AWSで様々な規模のデータレイクを分析する効率的な方法20180619 AWS Black Belt Online Seminar データレイク入門: AWSで様々な規模のデータレイクを分析する効率的な方法
20180619 AWS Black Belt Online Seminar データレイク入門: AWSで様々な規模のデータレイクを分析する効率的な方法
 
JAWS-UG Meets Windows (JAWS Days 2017)
JAWS-UG Meets Windows (JAWS Days 2017)JAWS-UG Meets Windows (JAWS Days 2017)
JAWS-UG Meets Windows (JAWS Days 2017)
 
20180704 AWS Black Belt Online Seminar Amazon Elastic File System (Amazon EFS...
20180704 AWS Black Belt Online Seminar Amazon Elastic File System (Amazon EFS...20180704 AWS Black Belt Online Seminar Amazon Elastic File System (Amazon EFS...
20180704 AWS Black Belt Online Seminar Amazon Elastic File System (Amazon EFS...
 
20211109 bleaの使い方(基本編)
20211109 bleaの使い方(基本編)20211109 bleaの使い方(基本編)
20211109 bleaの使い方(基本編)
 

Mais de Amazon Web Services Japan

202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)Amazon Web Services Japan
 
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFSAmazon Web Services Japan
 
202204 AWS Black Belt Online Seminar AWS IoT Device Defender
202204 AWS Black Belt Online Seminar AWS IoT Device Defender202204 AWS Black Belt Online Seminar AWS IoT Device Defender
202204 AWS Black Belt Online Seminar AWS IoT Device DefenderAmazon Web Services Japan
 
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現Amazon Web Services Japan
 
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...Amazon Web Services Japan
 
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデートAmazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデートAmazon Web Services Japan
 
20220409 AWS BLEA 開発にあたって検討したこと
20220409 AWS BLEA 開発にあたって検討したこと20220409 AWS BLEA 開発にあたって検討したこと
20220409 AWS BLEA 開発にあたって検討したことAmazon Web Services Japan
 
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用Amazon Web Services Japan
 
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdfAmazon Web Services Japan
 
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介Amazon Web Services Japan
 
Amazon QuickSight の組み込み方法をちょっぴりDD
Amazon QuickSight の組み込み方法をちょっぴりDDAmazon QuickSight の組み込み方法をちょっぴりDD
Amazon QuickSight の組み込み方法をちょっぴりDDAmazon Web Services Japan
 
マルチテナント化で知っておきたいデータベースのこと
マルチテナント化で知っておきたいデータベースのことマルチテナント化で知っておきたいデータベースのこと
マルチテナント化で知っておきたいデータベースのことAmazon Web Services Japan
 
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介Amazon Web Services Japan
 
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
202202 AWS Black Belt Online Seminar Amazon Connect Customer ProfilesAmazon Web Services Japan
 
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するためにAmazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するためにAmazon Web Services Japan
 
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨Amazon Web Services Japan
 
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介Amazon Web Services Japan
 
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介Amazon Web Services Japan
 
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...Amazon Web Services Japan
 

Mais de Amazon Web Services Japan (20)

202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
 
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
 
202204 AWS Black Belt Online Seminar AWS IoT Device Defender
202204 AWS Black Belt Online Seminar AWS IoT Device Defender202204 AWS Black Belt Online Seminar AWS IoT Device Defender
202204 AWS Black Belt Online Seminar AWS IoT Device Defender
 
Infrastructure as Code (IaC) 談義 2022
Infrastructure as Code (IaC) 談義 2022Infrastructure as Code (IaC) 談義 2022
Infrastructure as Code (IaC) 談義 2022
 
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
 
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
 
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデートAmazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
 
20220409 AWS BLEA 開発にあたって検討したこと
20220409 AWS BLEA 開発にあたって検討したこと20220409 AWS BLEA 開発にあたって検討したこと
20220409 AWS BLEA 開発にあたって検討したこと
 
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
 
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
 
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
 
Amazon QuickSight の組み込み方法をちょっぴりDD
Amazon QuickSight の組み込み方法をちょっぴりDDAmazon QuickSight の組み込み方法をちょっぴりDD
Amazon QuickSight の組み込み方法をちょっぴりDD
 
マルチテナント化で知っておきたいデータベースのこと
マルチテナント化で知っておきたいデータベースのことマルチテナント化で知っておきたいデータベースのこと
マルチテナント化で知っておきたいデータベースのこと
 
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
 
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
 
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するためにAmazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
 
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
 
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
 
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
 
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
 

Data Lake ハンズオン

  • 1. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Data Lake Hands-on
  • 2. 2 はじめに 幅広いデータソースからの構造化データまたは非構造化データの集中リポジトリとして使用で きる Data Lake は、データの保存と分析の方法として多くの企業に取り入れられています。 当セミナーでは、AWSのビッグデータ関連サービスを使用して実際に分析パイプラインを構 築することを通して、Data Lake と ビッグデータ分析基盤構築の実感を持って頂くことを ゴールとしています。 【準備事項】 AWSを利用可能なネットワークに接続されたPC(Windows, Mac OS, Linux等) 事前に用意していただいたAWSアカウント SSHクライアント(Windows環境ではTera Termを推奨) ブラウザ(FirefoxもしくはChromeを推奨)
  • 4. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ハンズオン概要
  • 5. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ハンズオン概要 6つのセクション ① はじめの準備(必須) 主に使用するAWSサービス:Amazon VPC, Amazon EC2, AWS CloudFormation, AWS IAM ② アプリケーションログをリアルタイムで可視化する 主に使用するAWSサービス:Amazon Elasticsearch Service ③ アプリケーションログのリアルタイム可視化とアラーム 主に使用するAWSサービス:Amazon CloudWatch, AWS Lambda, Amazon Elasticsearch Service ④ アプリケーションログの永続化と長期間データの分析と可視化 主に使用するAWSサービス:Amazon Kinesis Data Firehose, Amazon S3, Amazon Athena, Amazon QuickSight ⑤ クラウドDWHを使用したデータ分析 主に使用するAWSサービス: Amazon Kinesis Data Firehose, Amazon S3, Amazon Redshift, Amazon Redshift Spectrum, Amazon QuickSight ⑥ サーバーレスでデータのETL処理 主に使用するAWSサービス:AWS Glue, Amazon Athena 5
  • 6. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ニアリアルタイムデータ分析環境(スピードレイヤ) の構築 : ① -> ② -> ③ ① はじめの準備 主に使用するAWSサービス:Amazon VPC, Amazon EC2, AWS CloudFormation, AWS IAM ② アプリケーションログをリアルタイムで可視化する 主に使用するAWSサービス:Amazon Elasticsearch Service ③ アプリケーションログのリアルタイム可視化とアラーム 主に使用するAWSサービス:Amazon CloudWatch, AWS Lambda, Amazon Elasticsearch Service 6
  • 7. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. CloudWatch Logs Alarm Lambda Athena S3Kinesis Data Firehose QuickSight Glue S3 Redshift Elasticsearch 7 ニアリアルタイムデータ分析環境(スピードレイヤ) の構築 : ① -> ② -> ③
  • 8. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 長期間のデータをバッチ分析する環境(バッチレイヤ) の構築と、パフォーマンスとコストの最適化: ① -> ④ or ⑤ -> ⑥ ① はじめの準備 主に使用するAWSサービス:Amazon VPC, Amazon EC2, AWS CloudFormation, AWS IAM ④ アプリケーションログの永続化と長期間データの分析と可視化 主に使用するAWSサービス:Amazon Kinesis Data Firehose, Amazon S3, Amazon Athena, Amazon QuickSight ⑤ クラウドDWHを使用したデータ分析 主に使用するAWSサービス: Amazon Kinesis Data Firehose, Amazon Redshift, Amazon Redshift Spectrum, Amazon QuickSight ⑥ サーバーレスでデータのETL処理 主に使用するAWSサービス:AWS Glue, Amazon Athena 8
  • 9. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. CloudWatch Logs Alarm Lambda Athena S3Kinesis Data Firehose QuickSight Glue S3 Redshift Elasticsearch 9 長期間のデータをバッチ分析する環境(バッチレイヤ) の構築と、パフォーマンスとコストの最適化: ① -> ④ or ⑤ -> ⑥
  • 10. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. すべて実施 : ① -> ② -> ③ -> ④ -> ⑤ -> ⑥ ① はじめの準備 主に使用するAWSサービス:Amazon VPC, Amazon EC2, AWS CloudFormation, AWS IAM ② アプリケーションログをリアルタイムで可視化する 主に使用するAWSサービス:Amazon Elasticsearch Service ③ アプリケーションログのリアルタイム可視化とアラーム 主に使用するAWSサービス:Amazon CloudWatch, AWS Lambda, Amazon Elasticsearch Service ④ アプリケーションログの永続化と長期間データの分析と可視化 主に使用するAWSサービス:Amazon Kinesis Data Firehose, Amazon S3, Amazon Athena, Amazon QuickSight ⑤ クラウドDWHを使用したデータ分析 主に使用するAWSサービス: Amazon Kinesis Data Firehose, Amazon S3, Amazon Redshift, Amazon Redshift Spectrum, Amazon QuickSight ⑥ サーバーレスでデータのETL処理 主に使用するAWSサービス:AWS Glue, Amazon Athena 10
  • 11. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. すべて実施した場合の最終構成 CloudWatch Logs Alarm Lambda Athena S3Kinesis Data Firehose スピードレイヤでニアリアルタイム分析を行いながら、特定の条件時にアラームを飛ばしつ つ、すべてのログデータを安価に長期保存しながら、必要に応じてETL処理を行った上で、 アドホックにログデータに直接クエリしならがら分析すべきデータを見極めつつ、DWHで細 かく分析を行うと同時に、BIツールで可視化する構成を、ほぼサーバレスで実現する。 QuickSight Glue S3 Redshift Elasticsearch 11
  • 12. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ①はじめの準備 ログを生成し続けるEC2を作成する。CloudFormationからVPCやEC2を構築し、 手動でFluentdをインストールする。IAMロールを1つ作成しEC2にアタッチする。 12
  • 13. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ②アプリケーションログをリアルタイムで可視化する EC2で出力されるログをOSSのFluentdを使ってストリームでAmazon ESに転送 Amazon ESに付属しているKibanaでグラフィカルにデータを見る。 Elasticsearch 13
  • 14. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ③アプリケーションログのリアルタイム可視化と アラーム CloudWatch Logs Alarm Lambda ストリームの間にCloudWatchを入れリアルタイムログ監視を行う。 Elasticsearch 14
  • 15. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ④アプリケーションログの永続化と長期間データの分析 と可視化 AthenaS3Kinesis Data Firehose ストリーミングデータを直接データストアに永続化し、 長期間の保存を可能にした上で、アドホックな分析を行い、 BIツールで可視化する。 QuickSight 15
  • 16. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. S3Kinesis Data Firehose ストリーミングデータを直接データストアに永続化し、 長期間の保存を可能にした上で、DWHに読み込み分析し、 BIツールで可視化する。 Redshift Redshift Spectrum ⑤クラウドDWHを使用したデータ分析 16
  • 17. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ⑥サーバーレスでデータのETL処理 Athena S3Kinesis Data Firehose Glue S3 Glueを使ってデータの加工処理をサーバーレスで行う  ファイルフォーマットを”parquet”に変更  ファイルをパーティショニングした配置 Redshift spectrum 17
  • 18. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. すべて実施した場合の最終構成 CloudWatch Logs Alarm Lambda Athena S3Kinesis Data Firehose スピードレイヤでニアリアルタイム分析を行いながら、特定の条件時にアラームを飛ばしつ つ、すべてのログデータを安価に長期保存しながら、必要に応じてETL処理を行った上で、 アドホックにログデータに直接クエリしならがら分析すべきデータを見極めつつ、DWHで細 かく分析を行うと同時に、BIツールで可視化する構成を、ほぼサーバレスで実現する。 QuickSight Glue S3 Redshift Elasticsearch 18
  • 19. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ①はじめの準備
  • 20. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ①はじめの準備 ログを生成し続けるEC2を作成する。CloudFormationからVPCやEC2を構築し、 手動でFluentdをインストールする。IAMロールを1つ作成しEC2にアタッチする。 ※東京リージョンで実施 20
  • 21. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “キーペア” がない場合新規で作成します。AWSマネージメントコンソールから”EC2”をクリック ”キーペア”をクリック、[キーペア作成]をクリック、”キーペア名”を入力し[作成]をクリック 操作しているパソコンに秘密鍵(handson.pem)がダウンロードされます (1)SSHログイン方法(キーペアの作成) キーペアが既にある方は 飛ばしてください。 21
  • 22. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (1)SSHログイン方法 必要なもの • インスタンス作成時に指定したキーペアの秘密鍵ファイル (handson.pem) • インスタンスに割当たるパブリックIP SSHログイン方法 (具体的な操作方法は次ページより説明しています) • 接続先ホスト:インスタンスに割当たるパブリックIP • ログインユーザ名: ec2-user • 接続方法:公開鍵暗号方式(秘密鍵ファイルを指定) この後SSHログインと出てきたら以下の手順で進めてください 22
  • 23. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Windowsからログインする場合 • TeraTerm (ttssh.exe) を起動 http://sourceforge.jp/projects/ttssh2/ • 1.接続するインスタンスのパブリックDNS名を入力 • 2.SSH2を指定 • 3.「OK」をクリック • 4.この画面が出たら「続行」をクリック → 1 2 3 4 (1)SSHログイン方法 23
  • 24. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. • ユーザ名: ec2-user • 「RSA/DSA/ECDSA/ED25519鍵を使う」を選択 • 秘密鍵ファイル(handson.pem)を選択して接続 →→ 1 2 3 5 6 7 4. すべてのファイル(*.*)を選択する (選択しないと鍵が表示されない) 補足)この認証画面で時間が掛かりすぎた場合、タイムアウトに より「OK」をクリックしても繋がらない場合があります。その場合 は再度Teratermを起動してやり直してください。 (1)SSHログイン方法 24
  • 25. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Mac/Linuxからログインする場合 • ターミナルからコマンドラインでログイン (事前に秘密鍵 (pemファイル)のパーミッションを600にしないと接続出来 ません) $ chmod 600 ~/Downloads/handson.pem $ ssh -i ~/Downloads/handson.pem ec2-user@割当てたパブリックIPアドレス (1)SSHログイン方法(Macの場合) 25
  • 26. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.  インスタンスは完全に起動完了しているか?  起動時に指定した内容どおりに起動しているか?  接続先のIPアドレス あるいは ホスト名は正しいか?  指定したSecurity Groupは 22(SSH) や 3389 (RDP) を有効にしているか?  指定したKey Pairと対応する鍵ファイルを指定しているか?  秘密鍵ファイルのパーミッションは600になっているか?(Mac/Linuxから) (1)SSHログインがうまくいかない時 26
  • 27. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. CloudFormationを使いVPCの作成とログを出力し続けるEC2をこのVPCに構築 2分おきに10件前後のログを出力、10分おきに300件のエラーログを出力 (2)ログを生成するEC2を作成 security group VPC 27
  • 28. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWSマネージメントコンソールから”CloudFormation”を選択し、 [スタックの作成]をクリック (2)EC2を1台CloudFormationで構築 28
  • 29. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “テンプレートの選択“->”テンプレートをS3にアップロード”->[ファイルを選択]をクリックし、 ダウンロードしたテンプレート(1-minilake_ec2.yaml)を指定し[次へ]をクリック (2)EC2を1台CloudFormationで構築 利用Asset (asset1の”1-minilake_ec2.yaml”) 29
  • 30. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “スタックの名前”に”handson-minilake”(任意)、“キーペア”は任意のキーペアを指定して [次へ]をクリック。 (2)EC2を1台CloudFormationで構築 既にキーペア作成済なら、 任意のキーペアでも構い ません 30
  • 31. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “オプション”の”タグ”で、”キー”に Name “値”に handson-minilake と入力し、[次へ]。 最後の確認ページで[作成]をクリック。 数分ほど待つとEC2一台ができあがり/root/es-demo/testapp.logにログ出力が始まる (2)EC2を1台CloudFormationで構築 31
  • 32. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. EC2へのsshログインしてrootにスイッチし、ログが2分おきに出力していることを確認 ※画面はこの後も使うので開いたままにしておいてください。 $ sudo su - $ tail -f /root/es-demo/testapp.log (2)EC2を1台CloudFormationで構築 32
  • 33. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)EC2の設定  IAMロール作成とEC2にアタッチ  Fluentd のインストール 33
  • 34. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)EC2の設定(IAMロール作成とEC2にアタッチ) demo-minilakeでロール作成 EC2からAmazonESfullアクセスを付与 作成したロールをEC2にアタッチ EC2にAmazon ESにアクセスするためのIAM ロール作成 AWSマネージメントコンソールから”IAM”を選択し、”ロール”をクリック[ロールの作成] をクリックする 34
  • 35. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ”AWSサービス”をクリックし、[EC2]をクリック、[次のステップ: アクセス権限]をクリック (3)EC2の設定(IAMロール作成とEC2にアタッチ) 35
  • 36. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. そのまま[次のステップ:確認]をクリック ※この段階ではポリシーなしでロールを作ります (3)EC2の設定(IAMロール作成とEC2にアタッチ) 36
  • 37. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “ロール名”に”handson-minilake”と入力し、[ロールの作成]をクリック (3)EC2の設定(IAMロール作成とEC2にアタッチ) 37
  • 38. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWSマネージメントコンソールから”EC2”を選択し、”インスタンス”をクリックし、 今回作成したインスタンス(handson-minilake)にチェックを入れ、 [アクション]->”インスタンスの設定”->”IAMロールの割り当て/置換”をクリック (3)EC2の設定(IAMロール作成とEC2にアタッチ) 38
  • 39. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “IAMロール”で”handson-minilake”を選び、[適用]をクリック (3)EC2の設定(IAMロール作成とEC2にアタッチ) 39
  • 40. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)EC2の設定  IAMロール作成とEC2にアタッチ  Fluentd のインストール 40
  • 41. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)EC2の設定 (Fluentd) ログ収集ツールFluentdのインストール 41
  • 42. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)EC2の設定 (Fluentd) Fluentdとは  Treasure Dataが開発したOSS  Ruby製ツール  軽量  ログの収集、変換、転送  特に日本で人気  Pluggableなので拡張可能で様々なデータストアにリアルタイムログ転送  バッファリング、再送処理などの機能 ※ https://td-agent-package-browser.herokuapp.com/3/redhat/6/x86_64 42
  • 43. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)EC2の設定 (Fluentd) SSHログインし以下の設定を行う 利用Asset(asset1の”1-cmd.txt”コマンドリファレンス) • 以下コマンドを実行  redhat-lsb-coreとgccをインストール # yum -y install redhat-lsb-core gcc  td-agentをインストールする # rpm -ivh http://packages.treasuredata.com.s3.amazonaws.com/3/redhat/6/x86_64/td- agent-3.1.1-0.el6.x86_64.rpm • /etc/init.d/td-agentの18行目修正 TD_AGENT_USER=td-agentからTD_AGENT_USER=rootに編集 • Fluentdの自動起動設定(実際の起動は後ほど行います) # chkconfig td-agent on 43
  • 44. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ②アプリケーションログをリアルタ イムで可視化する
  • 45. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ②アプリケーションのログをリアルタイムで可視化する EC2で出力されるログをOSSのFluentdを使ってストリームでAmazon ESに送信 Amazon ESに付属しているKibanaでグラフィカルにデータを見る 45
  • 46. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Elasticsearch Service 特徴 ( https://aws.amazon.com/jp/elasticsearch-service/ ) • ElasticsearchのAPIをそのまま利用可能 • AWSのサービスと連携した構成を簡単に構築 例) • CloudWatch Logs -> Lambda -> Amazon ES • DynamoDB Streams -> Logstash -> Amazon ES • 検索ドメインを作成すると同時にKibanaが利用可能 • 日本語解析に対応 • Elasticsearch ICUプラグイン • Elasticsearch Kuromojiプラグイン 価格体系 ( https://aws.amazon.com/jp/elasticsearch-service/pricing/ ) • Elasticsearchインスタンス時間 • Amazon EBSストレージ ELK(Elasticsearch, Logstash, Kibana)スタックをサポートした マネージドAnalyticsサービス Logstash Amazon ESData Source
  • 47. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ②アプリケーションのログをリアルタイムで可視化する 2分おきに10件前後、10分おきに300件出力され続けるログを、Fluentdを使って AmazonESに転送しKibanaで可視化する 47
  • 48. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (1)Amazon ESの作成 AWSマネージメントコンソールから”Elasticsearch Service”を選択し [新しいドメインの作成]をクリック 48
  • 49. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (1)Amazon ESの作成 ドメイン名:handson-minilake バージョン:6.2 上記入力し[次へ]をクリック 49
  • 50. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (1)Amazon ESの作成 インスタンスタイプを無料枠対象である”t2.small.elasticsearch”を選ぶ 他はそのままにし画面右下の[次へ]をクリック 50
  • 51. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (1)Amazon ESの作成 ネットワーク構成を[パブリックアクセス]を選び、 ドメインアクセスポリシーの設定を[ドメインへのオープンアクセスを許可]を選ぶ 51
  • 52. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (1)Amazon ESの作成 注意事項が出ます。この設定は本番環境では推奨いたしません。 今回はハンズオンのため機密データも取り扱わないのでセキュリティをゆるくしてあります。 [リスクに同意します]にチェックを入れ[OK]をクリック、続けて[次へ]をクリック 52
  • 53. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (1)Amazon ESの作成 [確認]をクリックします。Amazon ESの作成が始まります。 構築完了には10分ほどかかりますが完了を待たずに次の手順を進めてください。 53
  • 54. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)EC2の設定  IAMロールにポリシー追加  Fluentd の設定 54
  • 55. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)IAM ロールにポリシー追加 作成済の”handson-minilake”のIAMロールに以下のポリシーを追加  AmazonESFullAccess AWSマネージメントコンソールから”IAM”を選択し、[ロール]をクリック [handson-minilake]のロール名をクリック 55
  • 56. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)IAM ロールにポリシー追加 [ポリシーのアタッチ]をクリック 56
  • 57. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 検索窓で”amazones”と入れ検索し、 “AmazonESFullAccess”に チェックを入れ、[ポリシーのアタッチ]をクリック (2)EC2の設定(IAMロール作成とEC2にアタッチ) 57
  • 58. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)IAM ロールにポリシー追加 正しくポリシーがアタッチされたことを確認する  AmazonESFullAccess 58
  • 59. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)EC2の設定  IAMロールにポリシー追加  Fluentd の設定 59
  • 60. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)EC2の設定 ログ収集ツールFluentdの設定 60
  • 61. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)EC2の設定 (Fluentd) 利用Asset(asset2の”2-cmd.txt”コマンドリファレンス) • 以下のコマンドを実行  Elasticsearchプラグインインストール # td-agent-gem install –v 2.6.0 fluent-plugin-elasticsearch  プラグインインストール確認 # td-agent-gem list | grep plugin-elasticsearch fluent-plugin-elasticsearch (2.6.0, 2.4.0) 61
  • 62. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)EC2の設定 (Fluentd) AmazonESのエンドポイントをエディタなどにコピーしておく (画面の赤枠内でhttps://は含めない) 利用Asset(asset2の”2-td-agent.conf” Fluentdの設定ファイル) • /etc/td-agent/td-agent.confの中身を削除(vimで開きコマンド “:%d” などで削除)、asset2 にある2-td-agent.confをエディタで開き中身をコピーして貼り付ける。貼り付けたあと内容 を一部修正、eshostをコピーしておいたエンドポイントで置き換え保存する https://以外の部 分をコピペ 62
  • 63. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)EC2の設定 (Fluentd) 利用Asset(asset2の”2-cmd.txt”コマンドリファレンス) • 以下のコマンド実行 # /etc/init.d/td-agent start • Fluentdのログ確認 # tail -f /var/log/td-agent/td-agent.log 上記ログにエラーが出続けるなどないことを確認 起動に成功した場合、以下の文言が出力されます [info]: #0 Connection opened to Elasticsearch cluster => { …. ※ログが出るまで少し時間かかる場合があります 63
  • 64. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)EC2の設定 (Fluentd) AWSマネージメントコンソールから”Elasticsearch Service”を選択し 作成したhandson-minilakeの設定の状態が”アクティブ”で検索可能なドキュメント の件数が1以上になっていることを確認し、[handson-minilake]ドメインをクリックする 64
  • 65. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)Kibanaの設定 ”Kibana”の右のURLをクリックする 65
  • 66. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)Kibanaの設定 Kibanaの左側メニューの”Management”をクリックし、右側の”Index Patterns” をクリック 66
  • 67. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)Kibanaの設定 “Index Pattern”に”testappec2log-*”を入力し、右側の[Next step]をクリック 67
  • 68. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)Kibanaの設定 “Time Filter field name”に”@timestamp”を選択し、右下の[Create index pattern] をクリック 68
  • 69. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)Kibanaの設定 利用Asset(asset2の” 2-visualization.json”,” 2-dashboard.json” Kibanaテンプレート) [Management]をクリックし”Saved Objects”をクリック [Import]をクリックし、asset2の以下2つを順番にインポートする。何度か確認のウインドウが 出るが[Yes, overwrite all objects]をクリックと、[Confirm all changes]をクリックし進める  2-visualization.json  2-dashboard.json ↓以下はインポート後の画面 69
  • 70. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)Kibanaの設定 [Dashboard]をクリックしインポートした”test1-dashboard”をクリック 以下のように値が表示されていればOK 70
  • 71. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)Kibanaの設定 右上でタイムレンジが選べる。期間を1時間にしてみる グラフ表示が1時間の間の取得値に変化している 71
  • 72. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)Kibanaの設定 [Discover]をクリックし、その右のメニューの[alarmlevel]をクリック アラームレベルごとの割合が見える 72
  • 73. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)Kibanaの設定 ”alarmlevel”の右のaddをクリックする。同じようにuserの右側のaddをクリックする 対象のカラム(時間、alarmlevel、user)だけが表示される ※”add”はカーソルがある時にだけ表示される 73
  • 74. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)Kibanaの設定 検索窓に以下を入力しエンターを押すと、”imai”というユーザーでフィルタリングされる user:”imai” ※検索窓右側の”Uses lucene query syntax”をクリックするとその他様々なクエリシンタックスが確認できます 74
  • 75. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)Kibanaの設定 • グラフ作成 http://mamelog.hatenablog.jp/entry/2017/03/04/161709 • 検索方法 https://qiita.com/toyama0919/items/9681ae866ce23a637316 • 検索窓に以下を入れて検索してみてください。 host: “prd-web002” • Kibana Console RESTのやり取りを直接インタラクティブに実行 例:GET /testapp-2018.02.20/testapplog/_search{ "query": { "match": { "user": "imai" } }} 好きなようにさわってみてください。 Enjoy Kibana! 75
  • 76. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ②【まとめ】 EC2からのログをストリームでAmazonESに送り、Kibanaで可視化して エラーログなどを探しやすくなりました。 大量のEC2がある場合ログを探すのは大変なのでさらに高い効果が見込めます 76
  • 77. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ②【もっと活用】 ログのストリーミングという考え方はAuto Scalingと相性がいい。AutoScalingはコスト圧縮も できる優れたソリューションだが、何も考慮しないとスケールイン時にログが消えてしまう ストリーミングでリアルタイムにログを出力することで解決! 77
  • 78. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (オプション1)Amazon ESへのアクセス制限 特定のIPアドレスからだけにアクセス制限を加える場合は、[アクセスポリシーの変更] をクリックします。 78
  • 79. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (オプション1)Amazon ESへのアクセス制限 [特定のIPからのドメインへのアクセスを許可]をクリックし、許可したいIPアドレスを カンマ区切りで入力します。今回であればログを送るEC2のEIPとKibanaにアクセス するオフィスのグローバルIP (IPアドレスは”自分のIP”などで検索してみてください)が 該当します。 79
  • 80. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (補足)Amazon ESのアップグレード New Amazon ES のダウンタイムなしでアップグレード可能になりました。 バージョン6.x -> バージョン6.3 バージョン5.6 -> バージョン6.3 バージョン5.x -> バージョン5.6 80
  • 81. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWSマネージメントコンソールから”Elasticsearch Service”を選択し 現在のバージョンが6.2であることを確認し、[handson-minilake]ドメインをクリックする (オプション2)Amazon ES のin-placeアップグレード 81
  • 82. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. [ドメインのアップグレード]をクリックする (オプション2)Amazon ES のin-placeアップグレード 82
  • 83. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. [ドメインのアップグレード]の画面で“アップグレードの適格性の確認”にチェックを入れ、 [送信]をクリックする。 (オプション2)Amazon ES のin-placeアップグレード 83
  • 84. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. アップグレードのポップアップが出て、アップグレード中は読み書き出来るが設定変更は できない旨が表示される。[続行]をクリックする。 (オプション2)Amazon ES のin-placeアップグレード 84
  • 85. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 数秒”アップグレード処理中”のステータスになりますがすぐ完了します。”アップグレード履歴“ タブをクリックしアップグレードの適格性の確認が”成功”したことを確認します。 (オプション2)Amazon ES のin-placeアップグレード 85
  • 86. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. アップグレードを行います。”アップグレード“にチェックを入れ、[送信]をクリックし、 ポップアップ画面で[続行]をクリックします。 (オプション2)Amazon ES のin-placeアップグレード 86
  • 87. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ステータスが”アップグレード処理”に変わります。アップグレードは、 アップグレードの適格性の確認->スナップショットの作成->アップグレード の順で進みます。 (オプション2)Amazon ES のin-placeアップグレード 87
  • 88. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 10数分かかるので次の作業進めてください。完了すると以下のようになります。 (オプション2)Amazon ES のin-placeアップグレード 88
  • 89. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ③アプリケーションログのリアルタ イム可視化とアラーム
  • 90. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ③アプリログのリアルタイム可視化とアラーム CloudWatch Logs Alarm Lambda ストリームの間にCloudwatchを入れリアルタイムログ監視を行う 90
  • 91. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ③アプリログのリアルタイム可視化とアラーム CloudWatch Logs Alarm Lambda ストリームの間にCloudwatchを入れリアルタイムログ監視を行う 監視 モニタリング 91
  • 92. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (1)IAM ロールにポリシー追加 作成済の”handson-minilake”のIAMロールに以下のポリシーを追加  CloudWatchLogsFullAccess AWSマネージメントコンソールから”IAM”を選択し、[ロール]をクリック [handson-minilake]のロール名をクリック 92
  • 93. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (1)IAM ロールにポリシー追加 [ポリシーのアタッチ]をクリック 93
  • 94. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (1)IAM ロールにポリシー追加 検索などを使いながら以下のポリシーを探してアタッチする  CloudWatchLogsFullAccess 94
  • 95. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)EC2の設定変更 (Fluentd) SSHログインし以下の設定を行う 利用Asset(asset3の”3-cmd.txt” コマンドリファレンス) ・以下のコマンドを実行 -cloudwatchlogsプラグインをインストール td-agent-gem install fluent-plugin-cloudwatch-logs -v 0.4.4 -プラグインインストールの確認 td-agent-gem list | grep cloudwatch-logs fluent-plugin-cloudwatch-logs (0.4.4) 95
  • 96. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)EC2の設定変更 (Fluentd) 利用Asset(asset3の”3-td-agent.conf” Fluentdの設定ファイル) ・/etc/td-agent/td-agent.confの中身を削除(viのコマンドの “:%d” などで削除)し、 asset3にある3-td-agent.confをエディタで開き中身をコピーして貼り付ける。 利用Asset(asset3の”3-cmd.txt “ コマンドリファレンス) ・/etc/init.d/td-agentの先頭に以下の行を追加する(13行目) export AWS_REGION="ap-northeast-1" ・fluentdリスタート /etc/init.d/td-agent restart ・fluentdのログ確認 tail -f /var/log/td-agent/td-agent.log 上記ログでエラーが出続けるなどないことを確認 96
  • 97. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)CloudWatch Logsの設定 AWSマネージメントコンソールから”CloudWatch”を選択し、”ログ”をクリック ロググループ”minilake_group”が出力されていることを確認しクリック ※数分待ってもログが出ない場合はEC2にIAMロールがアタッチされてるか確認 97
  • 98. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)CloudWatch Logsの設定 ログストリーム”testapplog_stream”をクリック 直近のログが出力されていることを確認 画面上部の”ロググループ”の文字列をクリックしロググループに戻る 98
  • 99. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)CloudWatch Logsの設定 ロググループ”minilake_group”にチェックを入れ、[アクション]をクリックし [Amazon Elasticsearch Serviceへのストリーミングの開始]をクリック。 ※裏側では自動でLambda Functionが作られます。 99
  • 100. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)CloudWatch Logsの設定 Amazon ESクラスターを、先に作った”handson-minilake”を選び Lambda IAM 実行ロールを、[新しいIAMロールの作成]を選択 ※ブラウザでポップアップブロックが走ったら、許可して、1つ前のスライドからやり直して下さい 100
  • 101. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)CloudWatch Logsの設定 ”lambda_elasticsearch_execution”という名前のロールが作られるので そのまま右下の[許可]をクリック 101
  • 102. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)CloudWatch Logsの設定 [次へ]をクリック 102
  • 103. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)CloudWatch Logsの設定 ログの形式に[その他]を選択し[次へ]をクリック、その後も[次へ]をクリック [ストリーミングの開始]をクリック 103
  • 104. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)ログの転送状況をKibanaから確認 Kibanaの画面を開き、[Management]をクリック、[Index Patterns]をクリック 104
  • 105. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)ログの転送状況をKibanaから確認 [Create Index Pattern]をクリック 105
  • 106. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)ログの転送状況をKibanaから確認 “Index pattern”に”cwl-*”を入力、[Next step]をクリック ※[Next step]がクリックできるようになるまで、少し時間がかかる場合があります 106
  • 107. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)ログの転送状況をKibanaから確認 “Time Filter field name” に”@timestamp” を選択し、[Create index pattern]をクリック 107
  • 108. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)ログの転送状況をKibanaから確認 [Discover]をクリック、その右のIndexを選ぶ箇所で”cwl-*”を選択する 値が取得されグラフが表示されていればOK 108
  • 109. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)Kibanaの設定 “Management”をクリックし”Saved Objects”をクリック 利用Asset(asset3の” 3-virtualize.json “,” 3-dashboard.json” Kibanaテンプレート) 画面右上の[Import]をクリックし、ダウンロードしたasset3の以下2つを順番にインポートする 何度か確認のウインドウが出るが[Yes, overwrite all objects]をクリックと、 New index patternに”cwl-*”を選び[Confirm all changes]をクリックで進める。 ※LambdaFunctionを修正してない場合は”cwl-*”  3-virtualize.json  3-dashboard.json ↓以下はインポート後の画面 109
  • 110. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (5)CloudWatchAlarm設定 AWSマネージメントコンソールから”CloudWatch”を選択し、”ログ”をクリック “minilake_group”のロググループにチェックを入れ[メトリクスフィルタの作成]をクリック 110
  • 111. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (5)CloudWatchAlarm設定 フィルタパターンに”ERROR”を入力。 ”パターンのテスト”で確認し、 右下の[メトリクスの割り当て]をクリック 111
  • 112. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (5)CloudWatchAlarm設定 “メトリクス名”を”minilake_errlog”と入力し[フィルタの作成]をクリック 112
  • 113. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (5)CloudWatchAlarm設定 フィルタが作成される。右側の”アラームの作成”をクリックし続けてアラーム設定を行う 113
  • 114. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (5)CloudWatchAlerm設定 • “名前”を”minilake_errlog” • “閾値”を”50”以上 • 間隔を”1分間” • アクションの通知を“新しい リスト”をクリックし、”通知の 送信先“に任意の文字列、” メールリスト”に受信できる メアドを入力 上記入力し[アラームの作成] をクリックする 114
  • 115. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (5)CloudWatchAlarm設定 確認のメールが送信されているので、メールを確認しリンクをクリックし ”Confirm Subscription”する 115
  • 116. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (5)CloudWatchAlarm設定 “CloudWatch”の”アラーム”をクリック、最初は状態が”データ不足”と表示されているが、 しばらくすると”OK”になる。1分間で50件以上”ERROR”が発生するとアラートが上がる。 10分ごとにERRORが300件出る設定になっているので10分毎にアラートが上がる 116
  • 117. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ③【まとめ】 CloudWatch Logs Alarm Lambda 以上でリアルタイムなモニタリングとログ監視ができました 117
  • 118. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ③【もっと活用】 CloudWatchの機能でログの監視・モニタリングは数クリックでとても簡単にできます CloudWatch Logsにどんなログが 出力されているでしょうか・・? CloudWatch Logs Alarm Lambda 一例を上げます • Lambdaのログ • ECSのログ • Glueのログ • CloudTrailのログ • VPC Flow Logsのログ などなど これらは全て同様の手順でアラーム設定、リアルタイムモニタリングが可能です 多くのAWSマネージドサービスがCloudWatch Logsにログ出力しています 118
  • 119. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (オプション)cwl-*では分かりづらいので修正 以下の修正をしたい場合、自動で作成されたLambda Functionを修正します  “cwl-*”ではわかりずらいので変更したい  @messageは全文なので不要な場合 【修正前】 119
  • 120. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWSマネージメントコンソールから”Lambda”を選択し、自動で作られたLambda関数 の”LogsToElasticsearch_handson-minilake”をクリックしコードを編集し[保存]をクリックする  “cwl-”->”testappcwllog-” (64行目)  @messageの行を削除 (71行目) 【修正後】 (オプション)cwl-*では分かりづらいので修正 120
  • 121. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ”Management”をクリック、[Create Index Pattern]をクリックし“Index Pattern”に ”testappcwllog-*”を入力し[Next step]をクリックし、次に[Create index pattern]を クリックする 【修正後】 (オプション)cwl-*では分かりづらいので修正 121
  • 122. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “Discover”から、新たに作成したIndexでグラフ表示出来ていることを確認 【修正後】 (オプション)cwl-*では分かりづらいので修正 122
  • 123. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “Management”をクリックし”Saved Objects”をクリック 利用Asset(asset3の” 3-virtualize.json “,” 3-dashboard.json” Kibanaテンプレート) 画面右上の[Import]をクリックし、ダウンロードしたasset3の以下2つを順番にインポートする 何度か確認のウインドウが出るが[Yes, overwrite all objects]をクリックと、 New index patternに”testappcwllog-*”を選び[Confirm all changes]をクリックで進める。 ※LambdaFunctionを修正してない場合は”cwl-*”  3-virtualize.json  3-dashboard.json ↓以下はインポート後の画面 (オプション)cwl-*では分かりづらいので修正 123
  • 124. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ④アプリケーションログの永続化と 長期間データの分析と可視化
  • 125. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ④アプリログの永続化と長期間データへの分析と可視化 AthenaS3Kinesis Data Firehose ストリーミングデータを直接データストアに永続化し、 長期間の保存を可能にした上で、アドホックな分析・可視化を行う QuickSight 125
  • 126. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. AthenaS3Kinesis Data Firehose ④アプリログの永続化と長期間データへの分析と可視化 QuickSight アドホックな 分析・可視化 データ永続化 ストリーミングデータを直接データストアに永続化し、 長期間の保存を可能にした上で、アドホックな分析・可視化を行う 126
  • 127. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (1)S3バケットを作成 AWSマネージメントコンソールから”S3”を選択し、画面の[バケットを作成する] をクリックする 127
  • 128. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (1)S3バケットを作成 バケット名に以下を入力し 左下の[作成] をクリック “20180315-handson-minilake-ueharaxx” ueharaのところはご自身の名字 xxにはご自身の誕生日の日にち ※S3バケット名はグローバルで一意である必要 があるので、バケット作成ができればバケット名 は任意でも構いません 128
  • 129. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)Kinesis Data Firehose作成 AWSマネージメントコンソールから”Kinesis”を選択し、 Kinesis Firehose 配信ストリームの[配信ストリームを作成する]をクリックする 129
  • 130. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)Kinesis Data Firehose作成 Delivery stream nameに”minilake1”と入力し、[Next]をクリック 130
  • 131. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)Kinesis Data Firehose作成 “Record transformation”をDisableのまま[Next]をクリック 131
  • 132. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)Kinesis Data Firehose作成 “Destination”でS3を選び 132
  • 133. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)Kinesis Data Firehose作成 “S3 bucket”は(1)で作ったバケットを選択。”Prefix”に”minilake-in1/”を入力、S3への出力時 のディレクトリとなりデフォルトだと指定プレフィックス配下に”YYYY/MM/DD/HH”が作られる。 最後に[Next]をクリック 133
  • 134. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)Kinesis Data Firehose作成 “Buffer interval”を”60”secondsにする。バッファリングは、Buffer sizeかBuffer interval のいずれかの条件がみたされるとS3に配信されます 今回は設定しませんが、 データの圧縮、暗号化も 可能です。大規模データ やセキュリティ要件に対し て有効に働きます 134
  • 135. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)Kinesis Data Firehose作成 “IAM role”で”Create new,or choose”をクリックし、FirehoseがS3にアクセスするための IAM ロールを作成します。 135
  • 136. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)Kinesis Data Firehose作成 作成するIAMロールの情報が表示、“ポリシードキュメントを表示”箇所をクリックする とポリシー内容が確認できます。 [許可]をクリックします。 136
  • 137. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)Kinesis Data Firehose作成 [Next]をクリックします。次にReview画面になりますので設定値が問題なければ [Create delivery stream]をクリックします。 137
  • 138. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)Kinesis Data Firehose作成 “Status”が”Creating”となります。数分で”Active”になるので次の手順に進めてください 138
  • 139. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)IAM ロールにポリシー追加 作成済の”handson-minilake”のIAMロールに以下のポリシーを追加  AmazonKinesisFirehoseFullAccess AWSマネージメントコンソールから”IAM”を選択し、[ロール]をクリック [handson-minilake]のロール名をクリック 139
  • 140. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)EC2側の設定変更  IAMロールにポリシー追加  Fluentd の設定 140
  • 141. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)IAM ロールにポリシー追加 [ポリシーのアタッチ]をクリック 141
  • 142. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)IAM ロールにポリシー追加 検索などを使いながら以下のポリシーを探してアタッチする  AmazonKinesisFirehoseFullAccess 142
  • 143. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)EC2側の設定変更  IAMロールにポリシー追加  Fluentd の設定 143
  • 144. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 利用Asset(asset4の”4-cmd.txt” コマンドリファレンス) ・以下のコマンドを実行 -Firehoseプラグインインストール td-agent-gem install fluent-plugin-kinesis -v 2.1.0 -プラグインインストール確認 td-agent-gem list | grep plugin-kinesis fluent-plugin-kinesis (2.1.0) (4)EC2側の設定変更(Fluentd設定) 144
  • 145. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 【①②③から続けてる場合】 利用Asset(asset4の”4-td-agent.conf1” Fluentd設定ファイル) 【①④から始めた場合】 利用Asset(asset4の”4-td-agent.conf2” Fluentd設定ファイル) ・/etc/td-agent/td-agent.confの中身を削除(viのコマンドの “:%d” などで削除)し、asset4に ある4-td-agent.confをエディタで開き中身をコピーして貼り付ける。 (4)EC2側の設定変更(Fluentd設定) 145
  • 146. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 【①④から始めた場合】 利用Asset(asset4の”4-cmd.txt” コマンドリファレンス) ・/etc/init.d/td-agentの先頭に以下の行を追加する(13行目) export AWS_REGION="ap-northeast-1" 【両方】 利用Asset(asset4の”4-cmd.txt” コマンドリファレンス) ・/etc/init.d/td-agent restart (4)EC2側の設定変更(Fluentd設定) 146
  • 147. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. S3にデータが出力されていることを確認 ※数分待つ (4)EC2側の設定変更(Fluentd設定) 147
  • 148. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Firehoseの画面で作成した”Delivery stream”の”minilake1”を選択し “Monitoring”タブをクリック、表示に時間がかかるので次の手順に進む (4)EC2側の設定変更(Fluentd設定) 148
  • 149. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (5)IAM ロールにポリシー追加 作成済の”handson-minilake”のIAMロールに以下のポリシーを追加  AWSGlueServiceRole  AmazonS3ReadOnlyAccess AWSマネージメントコンソールから”IAM”を選択し、[ロール]をクリック [handson-minilake]のロール名をクリック 149
  • 150. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (5)IAM ロールにポリシー追加 [ポリシーのアタッチ]をクリック 150
  • 151. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (5)IAM ロールにポリシー追加 検索などを使いながら以下の2つのポリシーを探してアタッチする  AWSGlueServiceRole  AmazonS3ReadOnlyAccess 151
  • 152. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ”信頼関係”タブをクリックし、[信頼関係の編集]ボタンをクリック (5)Glue Crawler用にIAMロール修正 152
  • 153. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 以下の画面で、”Service”: “ec2.amazonaws.com”の箇所にglueを追記する ※次ページ参照 (5)Glue Crawler用にIAMロール修正 153
  • 154. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. []でくくり、カンマで区切り、“glue.amazonaws.com”を追記する [信頼ポリシーの更新]をクリック (5)Glue Crawler用にIAMロール修正 154
  • 155. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWSマネージメントコンソールで”Glue”を選択。 ”クローラ”をクリック、[クローラの追加]をクリックする (6)Glue Crawlerを使ってスキーマを自動作成 155
  • 156. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “クローラの名前”に”minilake-in1”と入力し、[次へ]をクリック (6)Glue Crawlerを使ってスキーマを自動作成 156
  • 157. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “インクルードパス”に”作成した”S3バケット名/minilake-in1”を入力し [次へ]をクリック。次も[次へ]をクリック (6)Glue Crawlerを使ってスキーマを自動作成 157
  • 158. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “既存のIAMロールを選択”にチェックを入れ、作成したロール”handson-minilake”を選択し、 [次へ]をクリック。次の画面も”オンデマンドで実行”のままにし、[次へ]をクリック (6)Glue Crawlerを使ってスキーマを自動作成 158
  • 159. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “データベース”の[データベースの追加]をクリックし、ポップアップした画面で ”データベース名”に“minilake”と入力し、[作成]をクリックする (6)Glue Crawlerを使ってスキーマを自動作成 159
  • 160. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. [次へ]をクリック。次のページで[完了]をクリックする (6)Glue Crawlerを使ってスキーマを自動作成 160
  • 161. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 作成したクローラーの”minilake-in1”にチェックを入れ、[クローラの実行]をクリックする Statusが”Starting”になり、数分待つ。Statusが再度”Ready”に戻ったら左メニューの ”テーブル”をクリック (6)Glue Crawlerを使ってスキーマを自動作成 161
  • 162. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 以下の”minilake_in”のテーブルが作成されていることを確認し、 テーブル名の箇所をクリックしスキーマ定義を確認する (6)Glue Crawlerを使ってスキーマを自動作成 162
  • 163. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWSマネージメントコンソールで”Athena”を選択し データベースを”minilake”を選び、テーブルを先程作った”minilake_in1”を選び、 テーブル名の右端の”点マーク”をクリックし”テーブルのプレビュー”をクリックする (7)Athenaでクエリ実行 ※過去にAthenaを利用したことがあ る場合、データカタログをGlueのもの を使用するようアップデートが必要に なります。画面上に案内が表示されま すので、クリックして移行を行ってくだ さい。 163
  • 164. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. クエリ結果が下部に表示されることを確認。 (7)Athenaでクエリ実行 164
  • 165. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. SELECT * の結果 実行時間:1.71s、スキャンデータ量:93.08KB (7)Athenaでクエリ実行 165
  • 166. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Whereを付けた場合の結果 実行時間:2.66s、スキャンデータ量:195.61KB (7)Athenaでクエリ実行 好きなようにさわってみてください。 Enjoy Athena! 166
  • 167. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. SELECT * の結果 実行時間:4.39s、スキャンデータ量:6.07MB (参考)Athenaでクエリ実行 しばらく時間が経って データが溜まった状態 167
  • 168. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Whereを付けた場合の結果 実行時間:2.66s、スキャンデータ量:195.61KB (参考)Athenaでクエリ実行 しばらく時間が経って データが溜まった状態 168
  • 169. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Select * の場合 Whereを付けた場合の結果 (参考)Athenaでクエリ実行 実行時間:4.39s、スキャンデータ量:6.07MB 実行時間:2.66s、スキャンデータ量:195.6KB Athenaはスキャンしたデータ量による課金、スキャン量がすくなければコストも低く抑えられ さらにスキャン量が少なければパフォーマンス向上にもなる しばらく時間が経って データが溜まった状態 169
  • 170. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (参考)Athenaでクエリ実行 https://aws.amazon.com/jp/blogs/news/top-10-performance-tuning-tips-for-amazon-athena/ 読み取る量を減らす工夫でよく使われるのがパーティション、圧縮、カラムナフォーマット 170
  • 171. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWSマネージメントコンソールから”QuickSight”を選択し、QuickSightを初めて使う方は サインアップがまだされていないので以下の画面が出ます。”Sign up for QuickSight”を クリックします (8)QuickSight 171
  • 172. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “Create your QuickSight account”で “Standard”を選び、[Continue]をクリック (8)QuickSight 1GBまでは無料利用枠ですが、 無料利用期間が終わってる場合 は、1ヶ月単位で$12かかるので 費用気になる場合はQuickSight の部分は飛ばしても構いません 172
  • 173. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “QuickSight account name”に名前 “Notification email address”にメール アドレス “QuickSight capacity region”を Asia Pacific(Tokyo)を選択 [Finish]をクリック (8)QuickSight 173
  • 174. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. [Go to Amazon QuickSight]をクリックし、初回ログイン時のみ表示されるダイアログを消 去する。その後、右上のユーザー名をクリックし、“Manage QuickSight”をクリック (8)QuickSight ※この作業はバージニアリージョンで行う必要があります 174
  • 175. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “Account setting”をクリック “Edit AWS permissions”をクリック "Amazon Athena"にチェックを入れる "Amazon S3"の[Choose S3 buckets]をクリック "20180315-handson-minilake-ueharaxx"にチェックを入れ、[Select buckets]をクリック [Apply]をクリック 左上のQuickSightのロゴをクリック (8)QuickSight 175
  • 176. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. リージョンを”Asia Pacific (Tokyo)”に戻す (8)QuickSight [New analysis]をクリックする 176
  • 177. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. [New data set]をクリック (8)QuickSight 177
  • 178. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “Athena”をクリック、ポップアップ画面で”Data source name”に”minilake1”と入力し、 “Validate connection”をクリックし、成功したら[Create data source]をクリック (8)QuickSight 178
  • 179. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “Database”を”minilake”、Tablesを”minilake-in1”を選び、[Select]をクリックし、 “Finish data set creation”の画面で[Visualize]をクリック (8)QuickSight 179
  • 180. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. SPICEを選び、“Import Complete”の画面で準備完了 "Fields list"や"Visual types"を適当に選び、データが可視化されていることを確認 (8)QuickSight 好きなようにさわってみてください。 Enjoy QuickSight! 180
  • 181. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ④【まとめ】 AthenaS3KinesisDataFirehose ストリーミングデータを直接データストアに永続化し、 長期間の保存を可能にした上で、アドホックな分析・可視化を行う 基盤ができました。 181
  • 182. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ④【もっと活用】 Kinesis Data FirehoseはS3のみではなくRedshift、AmazonES、Splunkにもストリーミング 用のプログラムを書く必要なく直接ストリームデータ出力が可能。 S3KinesisDataFirehose Amazon Redshift AmazonES 必要な要件に合わせたパイプライン形成ができる 182
  • 183. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ⑥サーバーレスでデータのETL処理
  • 184. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ⑥サーバーレスでデータのETL処理 AthenaS3KinesisDataFirehose Glue S3 Glueを使ってデータの加工処理をサーバーレスで行います  ファイルフォーマットを”parquet”に変更  ファイルをパーティショニングした配置 184
  • 185. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ⑥サーバーレスでデータのETL処理 AthenaS3KinesisDataFirehose Glue S3 データ 永続化 モニタリングデータ 永続化 Glueを使ってデータの加工処理をサーバーレスで行います  ファイルフォーマットを”parquet”に変更  ファイルをパーティショニングした配置 185
  • 186. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (1)IAM ロール修正 186 【④を実施しなかった場合】 (1)を実施してください。 ④を実施した場合は(1)は飛ばして(2)から実施してください。
  • 187. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (1)IAM ロールにポリシー追加 作成済の”handson-minilake”のIAMロールに以下のポリシーを追加  AWSGlueServiceRole  AmazonS3ReadOnlyAccess AWSマネージメントコンソールから”IAM”を選択し、[ロール]をクリック [handson-minilake]のロール名をクリック 187
  • 188. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (1)IAM ロールにポリシー追加 [ポリシーのアタッチ]をクリック 188
  • 189. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (1)IAM ロールにポリシー追加 検索などを使いながら以下の2つのポリシーを探してアタッチする  AWSGlueServiceRole  AmazonS3ReadOnlyAccess 189
  • 190. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ”信頼関係”タブをクリックし、[信頼関係の編集]ボタンをクリック (1)Glue Crawler用にIAMロール修正 190
  • 191. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 以下の画面で、”Service”: “ec2.amazonaws.com”の箇所にglueを追記する ※次ページ参照 (1)Glue Crawler用にIAMロール修正 191
  • 192. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. []でくくり、カンマで区切り、“glue.amazonaws.com”を追記する [信頼ポリシーの更新]をクリック (1)Glue Crawler用にIAMロール修正 192
  • 193. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)IAM ロール修正 AWSマネージメントコンソールから”IAM”を選択し、”ロール”をクリック “handson-minilake”ロールをクリックし、[ポリシーのアタッチ]をクリック 193
  • 194. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (2)IAM ロールにポリシー追加 検索などを使いながら以下のポリシーを探してアタッチする  AmazonS3FullAccess 194
  • 195. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (3)S3に出力先のフォルダ作成 AWSマネージメントコンソールから”S3”を選択し、今回作成したバケットを選択。 [+フォルダ作成]をクリックし、フォルダ名に”minilake-out1”と入力し、[保存]をクリック 195
  • 196. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)GlueでETLジョブ作成と実行 AWSマネージメントコンソールから”Glue”を選択。 ”ジョブ”をクリックし、[ジョブの追加]をクリック。 196
  • 197. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)GlueでETLジョブ作成と実行 “名前”に”minilake1” ”IAMロール”に”handson-minilake” 上記入力 “詳細プロパティ”をクリック “スクリプトライブラリおよびジョブパラメータ” をクリック 197
  • 198. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “Job metrics”を”有効化” ※リソースのモニタリングが可能になります “ジョブ実行あたりの同時DPU”を”2”を 入力し、画面下の[次へ]をクリック ※DPUはGlueの処理能力でデフォルトは10 1DPU = 4vCPU,16GBメモリ (4)GlueでETLジョブ作成と実行 198
  • 199. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)GlueでETLジョブ作成と実行 “データソースの選択”で”minilake_in”にチェックを入れ、[次へ]をクリック 199
  • 200. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)GlueでETLジョブ作成と実行 ・“データターゲットの選択”で ・“データターゲットでテーブルを作成する” にチェック ・“データストア”を”Amazon S3” ・“フォーマット”を“Parquet” ・“ターゲットパス”を ” s3://20180315-handson-minilake-ueha raxx/minilake-out1”を選択 [次へ]をクリック 200
  • 201. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)GlueでETLジョブ作成と実行 ここで不要なカラムを排除したり、データ型の変更を行えます。今回はこのまま[次へ]をクリック 次のページで [ジョブを保存してスクリプトを修正する]をクリック 201
  • 202. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)GlueでETLジョブ作成と実行 [ジョブの実行]をクリックし、ポップアップ画面で[ジョブの実行]をクリックします 202
  • 203. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (参考)GlueでETLジョブ作成と実行 DAG SCRIPT LOG 203203
  • 204. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)GlueでETLジョブ作成と実行 AWSメニューからGlueをクリックしジョブをクリックし今回のジョブにチェックを入れる 10分程かかる場合もありますが、問題がなければ以下のように”実行ステータス”が ”Succeeded”となります。 ※ 時間があれば“Metrics”タブでリソースモニタリングも確認してください。 表示まで少し時間かかります 204
  • 205. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)GlueでETLジョブ作成と実行 “View additional metrics”をクリックすると詳細が見れますが、今回は値が小さすぎて 見づらいと思います。 205
  • 206. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (4)GlueでETLジョブ作成と実行 S3の”20180315-handson-minilake-ueharaxx/minilake-out1/”に ファイルが出力されていること 206
  • 207. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (5)Glueクローラーを作成と実行 Glueで出力データ用のクローラーを作る ”クローラ”をクリックし、[クローラの追加]をクリック 207
  • 208. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (5)Glueクローラーを作成と実行 “クローラの名前”に”minilake-out1”を入力し、[次へ]をクリック 208
  • 209. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (5)Glueクローラーを作成と実行 “インクルードパス”に“s3://20180315-handson-minilake-ueharaxx/minilake-out1” [次へ]をクリック 次もそのまま[次へ]をクリック 次に”既存のIAMロールを選択”をクリックし IAM ロールを”handson-minilake”を選び [次へ]をクリック 次もそのまま[次へ]をクリック 209
  • 210. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (5)Glueクローラーを作成と実行 “データベース”に”minilake”を選び 、 [次へ]をクリック。次のページで [完了]をクリック 210
  • 211. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (5)Glueクローラーを作成と実行 “minilake-out1”にチェックを入れ、[クローラの実行]をクリックし クローラーを実行する 211
  • 212. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (5)Glueクローラーを作成と実行 左メニューの”テーブル”をクリックし、テーブル名“minilake_out1”をクリックし スキーマ情報を確認する 212
  • 213. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (6)Athenaでクエリ比較 SELECT count(user) FROM "minilake"."minilake_in1" where user='uchida' and timestamp<='2018-02-19 21%' AND timestamp>='2018-02-18 12%'; 以下のクエリを入力データと出力データに対して行う  入力データ:CSV形式で日付でパーティション  出力データ:parquet形式 ※ uchidaさんをカウントしている 本日のログが出た時間が全て入 る様に指定してください。 213
  • 214. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (6)Athenaでクエリ比較 SELECT count(user) FROM "minilake"."minilake_in1" where user='uchida' and timestamp<='2018-02-19 21%' AND timestamp>='2018-02-18 12%'; “Run time”:6.71s “Data scanned”:6.72MB 入力データのCSV形式をクエリ しばらく時間が経って データが溜まった状態 214
  • 215. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (6)Athenaでクエリ比較 SELECT count(user) FROM "minilake"."minilake_out1" where user='uchida' and timestamp<='2018-02-19 21%' AND timestamp>='2018-02-18 12%'; “Run time”:8.63s “Data scanned”:84.25KB 出力データのparquet形式をクエリ しばらく時間が経って データが溜まった状態 215
  • 216. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (6)Athenaでクエリ比較 8.63s 84.25KB (1)CSVパーティション(日付) 6.71s 6.72MB (2)parquet Runtime Data scanned 不要なカラムを読まない分スキャ ン容量が少ない しばらく時間が経って データが溜まった状態 216
  • 217. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (6)Athenaでクエリ比較 2018-handson- minilake-xxx minilake-in1 2018 02 18 01 02 03 19 01 02 (1)CSVパーティション (日付) (2)parquet year month day hourS3内のフォルダ構造 ここをパーティションと呼ぶ 単なるフォルダ構造 217
  • 218. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 2018-handson- minilake-xxx minilake-in1 (6)Athenaでクエリ比較 2018 02 18 01 02 03 19 01 02 (1)CSVパーティション (日付) (2)parquet year month day hourS3内のフォルダ構造 ここをパーティションと呼ぶ 単なるフォルダ構造 2018年02月18日01時のデータを検索する時 緑の矢印の部分だけが読まれて不要なIOが発生せず パフォーマンスの向上とスキャン量が減ることでコストも低く抑えられる 218
  • 219. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 2018-handson- minilake-xxx minilake-in1 (6)Athenaでクエリ比較 2018 02 18 01 02 03 19 01 02 (1)CSVパーティション (日付) (2)parquet year month day hourS3内のフォルダ構造 ここをパーティションと呼ぶ 単なるフォルダ構造 uchidaさんで検索すると全件スキャンとなる userでパーティションが切られていないから 219
  • 220. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (6)Athenaでクエリ比較 2018-handson- minilake-xxx S3 minilake-out1 (1)CSVパーティション(日付) (2)parquet parquetは列指向フォーマットなので必要なカラムだけ読むが uchidaさんで検索するとファイル自体は全件スキャンとなる xxx1.parquet xxx2.parquet 220
  • 221. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 2018-handson- minilake-xxx parquetは列指向フォーマットなので必要なカラムだけ読むが uchidaさんで検索するとファイル自体は全件スキャンとなる (6)Athenaでクエリ比較 Minilake-out (1)CSVパーティション(日付) (2)parquet xxx1.parquet xxx2.parquet S3 221
  • 222. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (7)よくwhereする項目でパーティションを切る パーティションの意義は頻繁にWhereされる範囲を分割してスキャン量を減らすこと userでwhereするクエリが多いのであれば、userでパーティションを切ることで 不要なアクセスを減らせる。 222
  • 223. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (8)S3に出力用フォルダ作成 S3で”minilake-out2”フォルダを作成 223
  • 224. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (9)Glue ジョブ修正 “Glue”を開き、”ジョブ”から”minilake1”ジョブにチェックを入れ、[アクション]から ”スクリプトの編集”をクリック 224
  • 225. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (9)Glue ジョブ修正 右側のスクリプト編集箇所で”applymapping1”と”datasink4”の2箇所編集を加える 225
  • 226. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (9)Glue ジョブ修正 既存の”applymapping1”と”datasink4”の行をコメントアウトし、目印に###1の行を入れ それぞれの行の下にコマンドリファレンスのコードをコピペする ※コードは入り切らないのでリファレンス参照ください。 #datasink4 = glueContext.write_dynamic_frame.from_options(frame = dropnullfields3, connection_type = "s3", con ###1 datasink4 = glueContext.write_dynamic_frame.from_options(frame = dropnullfields3, connection_type = "s3", conn #applymapping1 = ApplyMapping.apply(frame = datasource0, mappings = [("timestamp", "string", "timestamp", "st ###1 applymapping1 = ApplyMapping.apply(frame = datasource0, mappings = [("timestamp", "string", "timestamp", "stri 226
  • 227. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (9)Glue ジョブ修正 利用Asset(asset6の”6-cmd.txt” コマンドリファレンス) コピーした行に以下の修正を加え[Save]。  datasink4には以下を追記 connection_options = {"path": "s3://20180315-handson-minilake-ueharaxx/minilake-out2", "partitionKeys": ["user","year", "month", "day","hour"]},format = "parquet")  applymapping1には以下を追記 ("partition_0", "string", "year", "string"), ("partition_1", "string", "month", "string"), ("partition_2", "string", "day", "string"), ("partition_3", "string", "hour", "string") Partition_0などはわかりずらいの でapplymapping関数でyearや monthに変換 Write_dynamic_frameの partitionKeysオプションを使い パーティション分割して出力指定 バケット名は、各自の命名に合わ せて修正 227
  • 228. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (9)Glue ジョブ修正 左上の[ジョブの実行]をクリック、ポップアップした画面で[ジョブの実行]をクリック 228
  • 229. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWSマネージメントコンソールで”Glue”を選択。 ”クローラ”をクリック、[クローラの追加]をクリックする (10)Glue Crawlerを使ってスキーマを自動作成 229
  • 230. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “クローラの名前”に”minilake-out2”と入力し、[次へ]をクリック (10)Glue Crawlerを使ってスキーマを自動作成 230
  • 231. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “インクルードパス”に“s3://20180315-handson-minilake-ueharaxx/minilake-out2 [次へ]をクリック。次のページも[次へ]をクリック (10)Glue Crawlerを使ってスキーマを自動作成 231
  • 232. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “既存のIAMロールを選択”にチェックを入れ、 作成したロールの”handson-minilake”を選択し、[次へ]をクリック 次の画面も”オンデマンドで実行”のままにし、[次へ]をクリック (10)Glue Crawlerを使ってスキーマを自動作成 232
  • 233. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “データベース”に”minilake”を選び、 [次へ]をクリック、次のページで [完了]をクリック (10)Glue Crawlerを使ってスキーマを自動作成 233
  • 234. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 作成したクローラーの”minilake-out2”にチェックを入れ、[クローラの実行]をクリックする ステータスが”Starting”になり、数分待つ。ステータスが再度”Ready”に戻ったら左メニューの ”テーブル”をクリック (10)Glue Crawlerを使ってスキーマを自動作成 234
  • 235. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. “minilake_out2”のテーブルが作成されていることを確認し、 テーブル名の箇所をクリックしテーブル内容を確認する (10)Glue Crawlerを使ってスキーマを自動作成 235
  • 236. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (11)Athenaでクエリ比較 “Run time”:8.73s “Data scanned”:19.57KB 出力のparquetパーティション形式 をクエリ SELECT count(user) FROM "minilake"."minilake_out2" where user='uchida' and timestamp<='2018-02-19 21%' AND timestamp>='2018-02-18 12%'; しばらく時間が経って データが溜まった状態 236
  • 237. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. uchida (11)Athenaでクエリ比較 2018-handson- minilake-xxx minilake-in1 2018 02 18 01 02 03 19 01 02 (1)CSVパーティション(日付) (2)parquet year month day hourS3内のフォルダ構造 ここをパーティションと呼ぶ 単なるフォルダ構造 uchidaさんで検索するとuchida配下のディレクトリだけがスキャンされる (3)Parquetパーティション(user) user kimura 2018 ・・ 237
  • 238. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 2018-handson- minilake-xxx minilake-in1 uchida (11)Athenaでクエリ比較 2018 02 18 01 02 03 19 01 02 (1)CSVパーティション(日付) (2)parquet year month day hourS3内のフォルダ構造 ここをパーティションと呼ぶ 単なるフォルダ構造 uchidaさんで検索するとuchida配下のディレクトリだけがスキャンされる (3)Parquetパーティション(user) user kimura 2018 ・・ 238
  • 239. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 2018-handson- minilake-xxx minilake-in1 uchida (11)Athenaでクエリ比較 2018 02 18 01 02 03 19 01 02 (1)CSVパーティション(日付) (2)parquet year month day hourS3内のフォルダ構造 ここをパーティションと呼ぶ 単なるフォルダ構造 uchidaさんで検索するとuchida配下のディレクトリだけがスキャンされる (3)Parquetパーティション(user) user kimura 2018 ・・ 239
  • 240. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (11)Athenaでクエリ比較 6.07s 1.39KB (1)CSVパーティション(日付) 4.51s 93.11KB (2)parquet Runtime Data scanned 8.03s 0.12KB(3)parquetパーティション(user) データがまだ少ないので みなさんの結果もこのく らいの値でしょうか? それでもparquetパー ティション形式のデータ に対してスキャンしてる 容量が少ないことがわか ります。 240
  • 241. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (11)Athenaでクエリ比較 8.63s 84.25KB 6.71s 6.72MB Runtime Data scanned 8.73s 19.57KB この値は数時間経った状 態です。 数時間経つとこのくらいの 結果になります。 (1)CSVパーティション(日付) (2)parquet (3)parquetパーティション(user) 241
  • 242. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (11)Athenaでクエリ比較 49.12s 84.25KB 18.54s 133.85MB Runtime Data scanned 8.18s 19.57KB CSVのままだと 2.5倍くらいの時間 全データスキャンし てるのでコストも かかる スキャン量も時間も 先程と変わらない 20日経って133MBのデー タだとこのくらいになります。 今回は数KBの小さいファイル が多くなってるので時間がか かっている。S3DistCPや HadoopのMergeなどでまと めることで速度改善する これはたかが133MB、データ量が さらに増えればこの差はより顕著 (1)CSVパーティション(日付) (2)parquet (3)parquetパーティション(user) 242
  • 243. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (10)Athenaでクエリ比較 10.88s 84.25KB (1)CSVパーティション 18.54s 133.85MB (2)parquet Runtime Data scanned 8.18s 19.57KB(3)parquetパーティション CSVのままだと 2.5倍くらいの時間 全データスキャンし てるのでコストも かかる スキャン量も時間も 先程と変わらない 20日経って133MBのデー タだとこのくらいになります。 https://aws.amazon.com/jp/blogs/news/top-10-performance-tuning-tips-for-amazon-athena/243
  • 244. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ⑥【まとめ】 AthenaS3KinesisDataFirehose Glue S3 以上でサーバーレスでのETL処理パイプラインができました。 行いたいクエリに対して最適なデータの形への変換処理 244
  • 245. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. ⑥【もっと活用】 今回Glueを使い、S3のデータを変換してS3出力しましたが、それ以外にも同じような変換 を行った出力をRedshiftやRDSやRDB on EC2に出力することも可能です。 またRDSやRedshiftやRDB on EC2を入力データにすることもできます。 Amazon Redshift ETL処理基板として様々なサービスに変換とロード可能 Glue S3 Amazon RDS Amazon Redshift Amazon RDS S3 ※Glueでは開発にApache Zeppelin Notebookを利用可能 Amazon DynamoDB New 245
  • 246. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (オプション1)repartition()で小さいファイルを まとめる • repartition()を使って小さいたくさんあるファイルをマージしてクエリ結果時間の確認 Glueジョブコードの入力と出力を変更してジョブ実行 クローラーを新規作成しクローリング、作成されたテーブルでAthenaクエリ実行 246 ・S3でフォルダ作成 ”minilake-out3”
  • 247. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (オプション1)repartition()で小さいファイルを まとめる 既存の”datasink4”の行をコメントアウトし、目印に###2の行を入れ 行の下にコマンドリファレンスのコードをコピペする ※コードは入り切らないのでリファレンス参照ください。 #datasink4 = glueContext.write_dynamic_frame.from_options(frame = dropnullfields3, connection_type = "s3", con ###2 df = dropnullfields3.toDF() df.repartition(4).write.mode("overwrite").parquet("s3://20180820-handson-minilake-ueharaxx/minilake-month-out1" 247
  • 248. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 利用Asset(asset6の”6-cmd.txt” コマンドリファレンス) コピーした行に以下の修正を加え[Save]して[実行]。  datasink4には以下を追記 df.repartition(4).write.mode("overwrite").parquet("s3://20180820-handson-minilake-ueharaxx/minilake-out3",compre  DataFrameに変換 df = dropnullfields3.toDF() パーティション数が出力ファイル 数になる。任意の値を入れる バケット名は、各自の命名に合わ せて修正 (オプション1)repartition()で小さいファイルを まとめる 248
  • 249. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (オプション1)repartition()で小さいファイルを まとめる 指定したパーティション数の4つのファイルが出力されている 249
  • 250. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (オプション1)repartition()で小さいファイルを まとめる クローラーを作成しクローリングを実行しテーブルを作成。 Athenaでクエリを実行し、 parquetファイルが多数あったminilake_out1テーブルとの差を確認する 時間:2.45s データ量:1.46KB 作成済のテーブル minilake_out1 250
  • 251. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (オプション1)repartition()で小さいファイルを まとめる クローラーを作成しクローリングを実行しテーブルを作成。 Athenaでクエリを実行し、 parquetファイルが多数あったminilake_out1テーブルとの差を確認する 時間:0.89s データ量:1.52KB 作成したテーブル minilake_out3 251
  • 252. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (オプション2) S3 Select で parquetファイルを開く 252 S3の画面から、今回作成したparquet ファイルを表示します。対象ファイルにチェックを入れ “アクション”->”S3 Select”をクリック
  • 253. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (オプション2) S3 Select で parquetファイルを開く 253 “Parquet”にチェックを入れる [ファイルプレビューの表示]をクリックする Parquetファイル内の5件が表示されます。 [次へ]をクリック
  • 254. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. (オプション2) S3 Select で parquetファイルを開く 254 SQLエディタで任意のクエリを実行してみてください。サンプルもあります。 従来簡単な確認のための表示が難しかったparquetファイルですが、このように簡単に確認できます。
  • 255. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Glue関連情報 • https://qiita.com/pioho07/items/32f76a16cbf49f9f712f Glue関連資料 255
  • 256. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. あとかたずけ この作業まで終えていない場合、継続して課金が発生いたしますので、 必ず行ってください。 256
  • 257. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. あとかたずけ ⑥ 1. Glue Job(ジョブ名:minilake1) 2. Crawlerの削除(クローラー名:minilake-in1、minilake-out1、minilake-out2) 3. Glue Tableの削除(テーブル名:minilake_out1、minilake_out2、minilake_month _out1) 4. Glue Databaseの削除(データベース名:minilake) 257
  • 258. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. あとかたずけ ⑤ 1. QuickSightのVPC Connectionsを削除 2. QuickSightのUnsubscribe(バージニアリージョンで行う必要があります) 3. S3バケットの削除(バケット名: 20180315-handson-minilake-ueharaxx) 4. KinesisFirehoseの削除(ストリーム名:minilake1) 5. Redshiftの削除 6. Glue Tableの削除(テーブル名:ec2log_external) 7. Glue Databaseの削除(データベース名:spectrumdb) 8. Redshiftクラスターの削除 258
  • 259. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. あとかたずけ ⑤ CloudFormationコンソールから、”handson-minilake-private-subnet”スタックを削除。 259
  • 260. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. あとかたずけ ④ 1. QuickSightのUnsubscribe(バージニアリージョンで行う必要があります) QuickSightのアカウント名クリック->Account settings->”Unsubscribe” 2. S3バケットの削除(バケット名: 20180315-handson-minilake-ueharaxx) 3. KinesisFirehoseの削除(ストリーム名:minilake1) 4. Glue Crawlerの削除(クローラー名:minilake1) 5. Glue Tableの削除(テーブル名:minilake_in1、minilake_out1、ec2log_external) 6. Glue Databaseの削除(データベース名:minilake、spectrumdb) 260
  • 261. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. あとかたずけ ③まで 1. Cloudwatch Logsの削除(ロググループ名以下) • 東京リージョン  /minilake_group  /aws/lambda/LogsToElasticsearch_handson-minilake  /aws/kinesisfirehose/minilake1  /aws-glue/crawlers/の”minilake1”ストリーム • /aws-glue/jobs/error、 /aws-glue/jobs/outputのストリームはジョブIDごとに 作成されます。Glueをいままで使っていなければロググループごとけしてください もし既存のログに影響をあたえず今回のログだけ削除したい場合はおこえかけく ださい 2. Lambdaの削除(Function名:LogsToElasticsearch-handson_minilake) 3. CloudwatchAlarm(アラーム名:minilake_errlog) 261
  • 262. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. あとかたずけ ②まで 1. AmazonESの削除 (ドメイン名:handson-minilake) 2. CloudFormationでスタック削除(EC2やEIPの削除) 3. IAMロールの削除(ロール名:handson-minilake) 262
  • 263. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. あとかたずけ ① CloudFormationコンソールから、”handson-minilake”スタックを削除。 263
  • 264. ©2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. 補足資料:AWSの技術リソース