SlideShare a Scribd company logo
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS 公式 Webinar
https://amzn.to/JPWebinar
過去資料
https://amzn.to/JPArchive
Solutions Architect 鈴木 太一郎
2020/5/26
AWS X-Ray
サービスカットシリーズ
[AWS Black Belt Online Seminar]
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
自己紹介
鈴木 太一郎
所属
• アマゾン ウェブ サービス ジャパン株式会社
技術統括本部
• ソリューションアーキテクト
好きなサービス
• AWS X-Ray
• AWS CDK
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Black Belt Online Seminar とは
「サービス別」「ソリューション別」「業種別」のそれぞれのテーマに分かれて、アマゾ
ン ウェブ サービス ジャパン株式会社が主催するオンラインセミナーシリーズです。
質問を投げることができます!
• 書き込んだ質問は、主催者にしか見えません
• 今後のロードマップに関するご質問は
お答えできませんのでご了承下さい
① 吹き出しをクリック
② 質問を入力
③ Sendをクリック
Twitter ハッシュタグは以下をご利用ください
#awsblackbelt
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
内容についての注意点
• 本資料では2020年5月26日時点のサービス内容および価格についてご説明しています。最新の
情報はAWS公式ウェブサイト(http://aws.amazon.com)にてご確認ください。
• 資料作成には十分注意しておりますが、資料内の価格とAWS公式ウェブサイト記載の価格に相
違があった場合、AWS公式ウェブサイトの価格を優先とさせていただきます。
• 価格は税抜表記となっています。日本居住者のお客様には別途消費税をご請求させていただきま
す。
• AWS does not offer binding price quotes. AWS pricing is publicly available and is
subject to change in accordance with the AWS Customer Agreement available at
http://aws.amazon.com/agreement/. Any pricing information included in this
document is provided only as an estimate of usage charges for AWS services based on
certain information that you have provided. Monthly charges will be based on your
actual use of AWS services, and may vary from the estimates provided.
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アジェンダ
• AWS X-Ray とは
• AWS X-Ray の概念
• AWS X-Ray によるアプリケーション分析
• AWS X-Ray によるデータ収集の仕組み
• AWS X-Ray の利用方法
• Amazon CloudWatch との連携
• 料金・注意点
• まとめ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アジェンダ
• AWS X-Ray とは
• AWS X-Ray の概念
• AWS X-Ray によるアプリケーション分析
• AWS X-Ray によるデータ収集の仕組み
• AWS X-Ray の利用方法
• Amazon CloudWatch との連携
• 料金・注意点
• まとめ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• モノリシック アプリケーション
 多数の機能を1プロセスで稼働
• マイクロサービス アプリケーション
 少数のまとまった機能を持つ複数のサービスで構成
 各サービスが独立したプロセスとして稼働
 サーバレスやコンテナと相性が良い
モノリシック vs マイクロサービス
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
モノリシック vs マイクロサービス
• モノリシック アプリケーション
 大規模アプリでは、高速なイテレーションが難しい
 効率的なスケールが難しい
 不具合や障害が全体に影響
• マイクロサービス アプリケーション
 各サービスで独立した開発・デプロイ
 各サービスで独立したスケーリング
 障害の直接的な影響が各サービス内
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マイクロサービスにおける障害対応・パフォーマンス分析
• 障害発生時の原因究明
• ログが分散・それぞれ独自のフォーマット
• 依存しあう多数の多様なサービス群
• パフォーマンス分析が難しい
• ボトルネックのサービスはどこなのか
• 日々変化するサービス間の依存関係と全体像
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray の概要
アプリケーションやその基盤となるサービスの実行状況を把握し
パフォーマンスの問題やエラーの根本原因を特定する
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray の概要
アプリケーションやその基盤となるサービスの実行状況を把握し
パフォーマンスの問題やエラーの根本原因を特定する
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray の概要
アプリケーションやその基盤となるサービスの実行状況を把握し
パフォーマンスの問題やエラーの根本原因を特定する
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray の概要
アプリケーションやその基盤となるサービスの実行状況を把握し
パフォーマンスの問題やエラーの根本原因を特定する
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray のメリット
リクエスト実行状況の確認
アプリケーションを構成する
個々のサービスやリソースの
実行結果ステータスを集計し、
アプリケーションの実行状況を
End-to-End で確認可能
アプリケーションの問題の検出
アプリケーションの実行状況に
ついての関連する情報を収集し、
問題の根本原因を調査可能
アプリケーションのパフォーマンス向上
サービスやリソースの関係をリアルタイムで
表示し、レイテンシ増加やパフォーマンス低下
などのボトルネックを特定可能
AWSとの連携
Amazon EC2, Amazon ECS,
AWS Lambda, AWS Elastic Beanstalk
などと連携
さまざまなアプリケーション向けの設計
非同期のシンプルなイベント呼び出し、
3層のウェブアプリケーション、数千の
サービスから構成される複雑なマイクロ
サービスも分析可能
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アジェンダ
• AWS X-Ray とは
• AWS X-Ray の概念
• AWS X-Ray によるアプリケーション分析
• AWS X-Ray によるデータ収集の仕組み
• AWS X-Ray の利用方法
• Amazon CloudWatch との連携
• 料金・注意点
• まとめ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray の概念
AWS Lambda
Amazon DynamoDB
AWS Lambda が Amazon DynamoDB を3回呼び出し
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray の概念
セグメント
動作に関するデータ
• リソース名
• リクエストの詳細
• 行った作業の詳細
Amazon DynamoDB
AWS Lambda
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray の概念
セグメント
サブセグメント
呼び出しに関する追加の詳細な情報
• AWS のサービス
• 外部 HTTP API
• SQL データベース
• など
Amazon DynamoDB
AWS Lambda
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray の概念
セグメント
Amazon API Gateway Amazon API Gateway AWS Fargate
Amazon S3
エンドユーザー
サブセグメント
Amazon DynamoDB
AWS Lambda
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray の概念
セグメント
エンドユーザー
トレース
サブセグメント
1つのリクエストで生成されたセグメントの全てを収集したもの
Amazon DynamoDB
AWS Lambda
Amazon S3
Amazon API Gateway Amazon API Gateway AWS Fargate
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
セグメント
Lambda
DynamoDB
API Gateway API Gateway Fargate
S3
エンドユーザー
トレース
サブセグメント
• どのようにトレースが含むセグメントを管理している?
• セグメントのつながり・順序はどう管理している?
AWS X-Ray の概念
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray の概念
どのようにトレースが含むセグメントを管理している?
• トレース ID
• リクエストを追跡するための ID
• リクエストごとに一意
• 基本的に最初にセグメントを生成するタイミングで生成
セグメント
トレース ID
(B)
セグメント
トレース ID
(B)
セグメント
トレース ID
(A)
トレース (B)
セグメント
トレース ID
(B)
セグメント
トレース ID
(B)
トレース (A)
セグメント
トレース ID
(A)
セグメント
トレース ID
(A)
AWS LambdaAmazon API Gatway
セグメント
トレース ID
(A)
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray の概念
セグメントのつながり・順序はどう管理している?
• セグメント ID
• トレース内のセグメントに対して一意に決まる
• 単一のサービスのリクエストを追跡するための ID
• 親セグメント ID によってセグメントのつながり・順序が決まる
セグメント (A)
親セグメント ID (B)
セグメント (C)
親セグメント ID (A)
セグメント (B)
セグメント (A)
親セグメント ID (B)
セグメント (C)
親セグメント ID (A)
セグメント (B)
トレース トレース
リクエストの流れ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray の概念
セグメント同士のつながりや順序はどう管理している?
• セグメント ID
• 単一のサービスのリクエストを追跡するためのID
• 親セグメント ID によってセグメントのつながりが決まる
セグメント
親セグメント
ID
セグメント
親セグメント
ID セグメント
セグメント
親セグメント
ID
セグメント
親セグメント
ID
セグメント
トレース トレース
トレース ID や セグメント ID をどう伝搬している?
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
X-Amzn-Trace-Id: Root=1-
57…93;Parent=53…d8;Sampled=1
AWS X-Ray の概念
トレース ID や セグメント ID をどう伝搬している?
• トレースヘッダー
• トレース ID、親セグメントID、サンプリングデシジョンが定義された
HTTP ヘッダー
トレース ID
親セグメント ID
サンプルデシジョン サンプリング対象か否か (1=true, 0=false)
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray の概念
セグメントに情報を追加したい
検索しやすくするため
• 注釈
• フィルタ式 (後述) で使用するためインデックス化されたキーと値のペ
ア
• 例 "aws:api_stage": "prod"
デバッグや分析のため
• メタデータ
• 任意のタイプの値を持つことができるキーと値のペア
• フィルタ式で使用するためのインデックスは作成されない
• 例 "game": {"id": "abcdefg", "session": "xxxyyyzzz"}
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アジェンダ
• AWS X-Ray とは
• AWS X-Ray の概念
• AWS X-Ray によるアプリケーション分析
• AWS X-Ray によるデータ収集の仕組み
• AWS X-Ray の利用方法
• Amazon CloudWatch との連携
• 料金・注意点
• まとめ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray によるアプリケーション分析
サービスマップ
トレースデータの可視化
トレースリスト
トレースの詳細な情報
アナリティクス
トレース分析用ツール
特定のサービスに関連する
トレースリストの確認
特定のサービスに関連する
トレースリストを分析
分析対象のトレースリストの
詳細を確認
End-to-End のリクエストの確認
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
サービスマップ
• 読み取れる情報
• フィルタ式
• グループ
サービスマップ
トレースリスト アナリティクス
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
サービスマップ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
サービスマップ
• 成功した呼び出し
• 4xx エラー
• 5xx エラー
• スロットリングエラー
平均レイテンシ (ms)
トレース数
(trace/min)
サービス名
サービスの分類
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
サービスマップ
クリック
アナリティクス トレースリスト
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
フィルタ式
• トレースを絞り込むための機能
• トレースリストとアナリティクスで利用可能
• duration >= 5 AND duration <= 8 総所要時間 が5秒〜8秒
• http.status != 200 レスポンスステータスが 200 OK ではない
• service(name) { filter } 特定のサービスを含んだリクエスト
• edge(source, destination) { filter } 特定のサービス間の接続
https://docs.aws.amazon.com/ja_jp/xray/latest/devguide/xray-console-
filters.html
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• トレースを絞り込むための機能
• トレースリストとアナリティクスで利用可能
• duration >= 5 AND duration <= 8 総所要時間 が5秒〜8秒
• http.status != 200 レスポンスステータスが 200 OK ではない
• service(name) { filter } 特定のサービスを含んだリクエスト
• edge(source, destination) { filter } 特定のサービス間の接続
フィルタ式
https://docs.aws.amazon.com/ja_jp/xray/latest/devguide/xray-console-
filters.html
クリック クリック
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• グループ
• フィルタ式で定義されるトレースのコレクション
• サービスマップ、トレースリスト、アナリティクスで利用可能
• Amazon CloudWatch にメトリクスを作成 (トレース数)
グループ
https://docs.aws.amazon.com/ja_jp/xray/latest/devguide/xray-console-
filters.html
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
トレースリスト
• トレースリスト
• セグメント・サブセグメント
• カスタムサブセグメント
• セグメント詳細
サービスマップ
トレースリスト アナリティクス
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
トレースリスト
トレースリスト
URL
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
トレースリスト
クリック
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
セグメント・サブセグメント
セグメント
サブセグメント
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
カスタムサブセグメント
カスタムサブセグメント
監視・計測したい機能ごとにサブセグメントとして切り出すことが可能
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
セグメント詳細
クリック
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
セグメント詳細
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
セグメント詳細
概要 注釈 例外
リソース メタデータ
セグメント情報
時間情報
エラー情報
リクエスト
レスポンス詳細
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アナリティクス
• フィルタリングされたトレースセット
• 応答時間の分布
• 時系列アクティビティ
• メトリクステーブル
• ワークルフローの例
サービスマップ
トレースリスト アナリティクス
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
フィルタリングされたトレースセット
• グラフやテーブルに対して操作を行いアナリティクス内に作成
• 最大で2つ ( A と B ) まで作成可能
• トレースセットを活用することで素早い分析が可能
グラフに対してドラッグ テーブルに対して選択
全てのトレース
グループ
フィルタリングの結果
フィルタリングされたトレースセット A
フィルタリングされたトレースセット B
アナリティクスで可視化されるトレース
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
応答時間の分布
• 指定された応答時間におけるトレース数を示すグラフ
• 横軸 応答時間
• 縦軸 トレース数
• ドラッグすることで フィルタリングされたトレースセット を作成できる
ドラッグ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• 指定された時間のトレース数
• 横軸 時間
• 濃さ トレース数 (濃い方が多い)
• ドラッグすることで フィルタリングされたトレースセット を作成できる
時系列アクティビティ
ドラッグ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Http Status Code や Response Time Root Cause など事前に定義された属性に
基づき分類されたトレース
• テーブルの行をクリックすることでフィルタリングされたトレースセット
として設定可能
メトリクステーブル
クリック
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• テーブルの属性は変更可能
• 注釈も指定できる
メトリクステーブル
クリック
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アナリティクスを用いたワークフローの例
1. リリースが応答時間に影響を与えていないか確認
• リリースした機能によってパフーマンスが悪化した場合
• パフォーマンス改善のリリースが効果的か調べる場合
2. 応答時間と時間帯に相関があるか調べる
• サービスの負荷が高まる時間帯に応答時間が長くなっていないか調べる場合
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ワークフローの例 ①
リリースが応答時間に影響を与えていないか確認したい
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ワークフローの例 ①
リリースが応答時間に影響を与えていないか確認したい
時系列アクティビティにてリリース後の期間をドラッグし
フィルタリングされたトレースセット A を作成
ドラッグ
リリースしたタイミング
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ワークフローの例 ①
リリースが応答時間に影響を与えていないか確認したい
応答時間の分布を確認し応答時間に影響がないことを確認
偏りがない
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ワークフローの例 ①
リリースが応答時間に影響を与えていないか確認したい
Http Status Code のテーブルを確認すれば
リリースがエラーを起こしていないか確認できる
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ワークフローの例 ②
応答時間と時間帯に相関があるか調べる
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ワークフローの例 ②
応答時間と時間帯に相関があるか調べる
応答時間の早い トレースセット A を作成
ドラッグ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ワークフローの例 ②
応答時間と時間帯に相関があるか調べる
応答時間の遅い トレースセット B を作成
ドラッグ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ワークフローの例 ②
応答時間と時間帯に相関があるか調べる
時系列アクティビティを確認し
分布に偏りがないことから時間との相関はないと判断
偏りがない
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
サンプリング
• サンプリングとは
• サンプリングの作成
• ルール名・優先度
• リザーバサイズ・固定レート
• 一致基準
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
サンプリングとは
• AWS X-Ray ではサンプリングルールに従い記録されるリクエストが決まる
• デフォルトのサンプリングルール
• 1秒ごとに最初のリクエストは必ずトレースされる
• それ以降のリクエストについては全体の5%がトレースされる
• なぜサンプリングが必要?
• 課金額のコントロール
• パフォーマンスへの影響をコントロール
• 設定方法
• コンソール
• ローカルルール ( SDK から設定を読み込む )
今からご紹介
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
サンプリングの作成
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
サンプリングの作成
全ての条件に一致
ルールが適応されたトレース数
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
サンプリングの作成
クリック
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ルール名・優先度
値が低い方が優先的に適応
デフォルトのルールは10000
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
リザーバサイズ・固定レート
デフォルトはリザーバサイズ= 1 固定レート=5%
• リザーバサイズ 1秒間で必ず記録するトレース数
• 固定レート リザーバサイズを超えたリクエスト数のうち何%を記録するか
リザーバサイズ=50 固定レート=10%
1秒あたり100件のリクエストがルールに一致する場合
50 (リザーバーサイズ) + 50 x 0.1 (固定レート) = 55 リクエスト
例
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
一致基準
例: AWS::APIGateway::Stage
例: POST
例: /api/
例: arn:aws:execute-api…
例: webserver.mydomain.com
例: MyApplication
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アジェンダ
• AWS X-Ray とは
• AWS X-Ray の概念
• AWS X-Ray によるアプリケーション分析
• AWS X-Ray によるデータ収集の仕組み
• AWS X-Ray の利用方法
• Amazon CloudWatch との連携
• 料金・注意点
• まとめ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray のデータ収集の仕組み
スクリプトやツール
AWS SDK AWS CLI
AWS X-Ray SDK
アプリケーション
AWS X-Ray API
AWS X-Ray コンソール
AWS X-Ray デーモン
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray のデータ収集の仕組み
スクリプトやツール
AWS SDK AWS CLI
AWS X-Ray SDK
アプリケーション
AWS X-Ray API
AWS X-Ray コンソール
AWS X-Ray デーモン
アプリケーションで作成したセグメントデータを
X-Ray デーモンに送信
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray SDK
Java
Node.js
.Net
Ruby
Go
Python
• トレースデータを作成して X-Ray デーモンに送信するた
めのクラスとメソッドを提供
• 受信リクエスト
• AWS SDK クライアント (Amazon DynamoDB, Amazon
S3, …)
• 送信 HTTP 呼び出し
• SQL クエリ
• カスタムサブセグメント
• …
AWSX-Ray SDK
アプリケーション
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray のデータ収集の仕組み
スクリプトやツール
AWS SDK AWS CLI
AWS X-Ray SDK
アプリケーション
AWS X-Ray API
AWS X-Ray コンソール
AWS X-Ray デーモン
X-Ray デーモンはセグメントデータを
バッファリングし X-Ray API に定期的に転送
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray デーモン
• 未加工のセグメントデータを収集して AWS X-Ray API に送信
• UDP ポート 2000 (デフォルト) をリッスン
• 受信したデータをバッファリングして X-Ray API に送信する
• 実行方法
• Linux 実行可能ファイル, RPMパッケージ, DEBパッケージ
• OS X 実行可能ファイル
• Windows 実行可能ファイル, サービス
• AWS Lambda コンソールから設定
• AWS Elastic Beanstalk コンソールから設定
• Amazon ECS Sidecar として実行 AWS X-Ray デーモン
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray のデータ収集の仕組み
スクリプトやツール
AWS SDK AWS CLI
AWS X-Ray SDK
アプリケーション
AWS X-Ray API
AWS X-Ray コンソール
AWS X-Ray デーモン
収集されたセグメントデータから
トレースを作成
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray のデータ収集の仕組み
スクリプトやツール
AWS SDK AWS CLI
AWS X-Ray SDK
アプリケーション
AWS X-Ray API
AWS X-Ray コンソール
AWS X-Ray デーモン
X-Ray SDK を使わずに直接 X-Ray API と
データのやり取りをすることも可能
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray API
• AWS X-Ray の全ての機能にアクセス可能
• トレースの追加・取得・更新
• グループの作成・取得・更新・削除
• サンプリングルールの作成・取得・更新・削除
• 利用方法
• HTTPS 経由
• AWS SDK 経由
• AWS Command Line Interface 経由
AWS X-Ray API
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray のデータ収集の仕組み
スクリプトやツール
AWS SDK AWS CLI
AWS X-Ray SDK
アプリケーション
AWS X-Ray API
AWS X-Ray コンソール
AWS X-Ray デーモン
トレースをコンソールで可視化
分析・デバッグを行う
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アジェンダ
• AWS X-Ray とは
• AWS X-Ray の概念
• AWS X-Ray によるアプリケーション分析
• AWS X-Ray によるデータ収集の仕組み
• AWS X-Ray の利用方法
• Amazon CloudWatch との連携
• 料金・注意点
• まとめ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Lambda
• トレースの有効化は AWS Lambda 関数の設定から
• 多少のメモリ消費量の増加あり
• HTTP 呼び出し・注釈・メタデータの追加などには
AWS X-Ray SDK が必要
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon API Gateway
• ステージの設定から X-Ray トレースの有効化
• HTTP リクエストにトレースヘッダーを追加
• AWS X-Ray コンソールで定義したサンプリングルール
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Elastic Beanstalk
• ソフトウェアから AWS X-Ray を有効化
• アプリケーションに AWS X-Ray SDK を組み込む作業は必要
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon EC2
• X-Ray デーモンが実行可能な OS
• Amazon Linux
• Ubuntu
• Windows Server (2012 R2 以降)
• インスタンス起動時にユーザーデータのスクリプトを実行してデーモンを起動
#!/bin/bash
curl https://s3.dualstack.us-east-
2.amazonaws.com/aws-xray-assets.us-east-2/xray-
daemon/aws-xray-daemon-3.x.rpm -o /home/ec2-
user/xray.rpm
yum install -y /home/ec2-user/xray.rpm
Amazon Linux の例
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• AWS X-Ray デーモンの Docker コンテナを Sidecar として設定
• ネットワークモードによってコンテナ周りのタスク定義の設定が異なる
• ブリッジ (デフォルト) リンクを作成し 環境変数 AWS_XRAY_DAEMON_ADDRESS に向き
先を設定
• awsvpc 特に設定は必要ない
{
"name": "xray-daemon",
"image": "amazon/aws-xray-
daemon",
"cpu": 32,
"memoryReservation": 256,
"portMappings" : [
{
"hostPort": 0,
"containerPort": 2000,
"protocol": "udp"
}
],
}
AWS X-Ray デーモン
AWS X-Ray API
アプリケーション
AWS X-Ray
SDK
Amazon ECS タスク
AWS X-Ray デーモン
アプリケーション
AWS X-Ray
SDK
Amazon ECS タスク
Amazon ECS
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS App Mesh
• AWS App Mesh の Envoy プロキシに環境変数 ENABLE_ENVOY_XRAY_TRACING: ”1”に設定するこ
とで
AWS X-Ray デーモン (127.0.0.1:2000) にデータを転送
• AWS AppMeshが動作している環境に応じて AWS X-Ray デーモンの設定が必要
AWS X-Ray デーモン
AWS X-Ray API
アプリケーション
AWS X-Ray
SDK
Amazon ECS タスク
AWS App Mesh Sidecar
AWS X-Ray デーモン
アプリケーション
AWS X-Ray
SDK
Amazon ECS タスク
AWS App Mesh Sidecar
Amazon ECS の例
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon SQS, Amazon SNS
• Amazon SQS と Amazon SNS とも統合
• 統合を有効化する設定は必要ない
パッシブ計測 別のサービスですでにサンプリングされているリクエストを計測 Amazon SQS, Amazon SNS
アクティブ計測 受信リクエストをサンプリングして計測 Amazon API Gateway, AWS
Lambda
*)Amazon API Gateway と AWS Lambda はパッシブ計測も可能
パッシブ計測
AWS Lambda
Amazon SQS
コンシューマー
Amazon SQS の例
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS SAM, CDK
• AWS SAM, CDK から X-Ray の有効化が可能
Type:
AWS::Serverless::Function
Properties:
FunctionName: MyFunction
Handler: index.handler
Tracing: Active
...
const myFunction = new lambda.Function(this,
'myFunction', {
functionName: 'MyFunction',
handler: 'index.handler',
tracing: lambda.Tracing.ACTIVE,
...
});
AWS SAM CDK (Typescript)
AWS Lambda の例
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray SDK (Node.js)
• 受信リクエストのトレース ( express の例 )
const app = express();
const AWSXRay = require('aws-xray-sdk');
app.use(AWSXRay.express.openSegment('MyAp
p'));
app.get('/', function (req, res) {
res.render('index');
});
app.use(AWSXRay.express.closeSegment());
const AWSXRay = require('aws-xray-sdk');
AWSXRay.captureHTTPsGlobal(require('http’));
AWSXRay.capturePromise(); // request-promise, axios
利用時
// http を利用する場合
const http = require('http’);
// request を利用する場合
const request = require('request’);
// axios を利用する場合
const axios = require('axios’);
• HTTPリクエストのトレース
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray SDK (Node.js)
• AWS サービス呼び出しのトレース • カスタムサブセグメントの生成
const AWS = AWSXRay.captureAWS(require('aws-
sdk'));
const s3 = new AWS.S3();
// s3 を利用した呼び出しはトレースされる
const AWSXRay = require('aws-xray-sdk');
AWSXRay.captureFunc('SubSegment1', (subsegment) =>
{
console.log('hello!');
});
AWSXRay.captureAsyncFunc('SubSegment2',
(subsegment) => {
setTimeout(() => { subsegment.close() }, 1000);
});
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アジェンダ
• AWS X-Ray とは
• AWS X-Ray の概念
• AWS X-Ray によるアプリケーション分析
• AWS X-Ray によるデータ収集の仕組み
• AWS X-Ray の利用方法
• Amazon CloudWatch との連携
• 料金・注意点
• まとめ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon CloudWatch ServiceLens
• Amazon CloudWatch と AWS X-Ray を統合
• トレース
• メトリクス
• ログ
• アラート
AWS X-Ray のデータを利用
サービスマップ
メトリクスグラフ、アラート
Amazon CloudWatch Logs インサイト
トレースの一覧やフィルタリング機能
メトリクスの詳細やノードマップ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon CloudWatch Synthetics
• Canaryを作成してエンドポイントを監視
• Canaryとは
• 特定のエンドポイントにアクセス
• 定期的なスケジュールで実行
• ロード時間データとUIのスクリーンショットを保存
• 閾値によってアラームを作成
Canary実行
サービスマップ
• Amazon CloudWatch ServiceLens、AWS X-Ray と統合
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アジェンダ
• AWS X-Ray とは
• AWS X-Ray の概念
• AWS X-Ray によるアプリケーション分析
• AWS X-Ray によるデータ収集の仕組み
• AWS X-Ray の利用方法
• Amazon CloudWatch との連携
• 料金・注意点
• まとめ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
料金 (2020/5/26 現在)
• 記録、取得、スキャンされたトレースの数に基づいて料金が発生
• 永続的な無料利用枠
• 毎月 トレースの記録は 10 万回まで無料
• 毎月 トレースの取得とスキャンは合わせて 100 万回まで無料
トレースの記録 100 万件あたり 5.00USD
トレースの取得 100 万件あたり 0.50USD
トレースのスキャン 100 万件あたり 0.50USD
* 無料利用枠を超えた分
* リージョン アジアパシフィック (東京)
https://aws.amazon.com/xray/pricing/
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
注意点
• サンプリングについて
• デフォルトではサンプリングされる
• 100% トレースする設定も可能だが、料金とパフォーマンスへの影響
を事前に確認する
• データの完全性は保証されない
• 監査やコンプライアンスのツールとして使用することはできない
• 直近 30 日間の追跡データが保存
• 過去 30 日間の追跡データに対してクエリを実行可能
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
アジェンダ
• AWS X-Ray とは
• AWS X-Ray の概念
• AWS X-Ray によるアプリケーション分析
• AWS X-Ray によるデータ収集の仕組み
• AWS X-Ray の利用方法
• Amazon CloudWatch との連携
• 料金・注意点
• まとめ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
まとめ
AWS X-Ray
有用なツール群
• サービスマップ マイクロサービスアプリケーションにおいて把握が難しい
サービス間の依存関係をわかりやすく可視化
• トレースリスト 詳細なトレースデータにアクセス可能
セグメントやサブセグメントの実行状況を可視化
• アナリティクス インタラクティブな操作によって素早い分析が可能
利用の容易さ
 AWS X-Ray SDK や AWS X-Ray デーモンによってアプリケーションに簡単に組み込める
 多くの AWS サービスと統合されていて簡単にセットアップ可能
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Q&A
お答えできなかったご質問については
AWS Japan Blog 「https://aws.amazon.com/jp/blogs/news/」にて
後日掲載します。
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS の日本語資料の場所「AWS 資料」で検索
https://amzn.to/JPArchive
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
で[検索]AWS イベント
毎週”W-A個別技術相談会”を実施中
• AWSのソリューションアーキテクト(SA)に
対策などを相談することも可能
• 申込みはイベント告知サイトから
(https://aws.amazon.com/jp/about-aws/events/)
AWS Well-Architected 個別技術相談会
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS 公式 Webinar
https://amzn.to/JPWebinar
過去資料
https://amzn.to/JPArchive
ご視聴ありがとうございました

More Related Content

PDF
20191016 AWS Black Belt Online Seminar Amazon Route 53 Resolver
Amazon Web Services Japan
 
PDF
20190806 AWS Black Belt Online Seminar AWS Glue
Amazon Web Services Japan
 
PDF
20210126 AWS Black Belt Online Seminar AWS CodeDeploy
Amazon Web Services Japan
 
PDF
20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)
Amazon Web Services Japan
 
PDF
20200422 AWS Black Belt Online Seminar Amazon Elastic Container Service (Amaz...
Amazon Web Services Japan
 
PDF
20210216 AWS Black Belt Online Seminar AWS Database Migration Service
Amazon Web Services Japan
 
PDF
AWS Black Belt Online Seminar 2017 AWS Elastic Beanstalk
Amazon Web Services Japan
 
PDF
20210526 AWS Expert Online マルチアカウント管理の基本
Amazon Web Services Japan
 
20191016 AWS Black Belt Online Seminar Amazon Route 53 Resolver
Amazon Web Services Japan
 
20190806 AWS Black Belt Online Seminar AWS Glue
Amazon Web Services Japan
 
20210126 AWS Black Belt Online Seminar AWS CodeDeploy
Amazon Web Services Japan
 
20190521 AWS Black Belt Online Seminar Amazon Simple Email Service (Amazon SES)
Amazon Web Services Japan
 
20200422 AWS Black Belt Online Seminar Amazon Elastic Container Service (Amaz...
Amazon Web Services Japan
 
20210216 AWS Black Belt Online Seminar AWS Database Migration Service
Amazon Web Services Japan
 
AWS Black Belt Online Seminar 2017 AWS Elastic Beanstalk
Amazon Web Services Japan
 
20210526 AWS Expert Online マルチアカウント管理の基本
Amazon Web Services Japan
 

What's hot (20)

PDF
20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用
Amazon Web Services Japan
 
PDF
AWS Black Belt Online Seminar 2018 Amazon DynamoDB Advanced Design Pattern
Amazon Web Services Japan
 
PDF
20201028 AWS Black Belt Online Seminar Amazon CloudFront deep dive
Amazon Web Services Japan
 
PDF
20200630 AWS Black Belt Online Seminar Amazon Cognito
Amazon Web Services Japan
 
PDF
AWS Black Belt Online Seminar Amazon Aurora
Amazon Web Services Japan
 
PDF
20200826 AWS Black Belt Online Seminar AWS CloudFormation
Amazon Web Services Japan
 
PDF
20190730 AWS Black Belt Online Seminar Amazon CloudFrontの概要
Amazon Web Services Japan
 
PDF
AWS Black Belt Online Seminar 2017 Amazon ElastiCache
Amazon Web Services Japan
 
PDF
20191029 AWS Black Belt Online Seminar Elastic Load Balancing (ELB)
Amazon Web Services Japan
 
PDF
Amazon Simple Workflow Service (SWF)
Amazon Web Services Japan
 
PDF
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
Amazon Web Services Japan
 
PDF
AWS Black Belt Online Seminar 2016 AWS CloudFormation
Amazon Web Services Japan
 
PDF
20190226 AWS Black Belt Online Seminar Amazon WorkSpaces
Amazon Web Services Japan
 
PDF
AWS Black Belt Online Seminar 2016 AWS上でのActive Directory構築
Amazon Web Services Japan
 
PDF
20190319 AWS Black Belt Online Seminar Amazon FSx for Windows Server
Amazon Web Services Japan
 
PDF
AWS Black Belt Online Seminar 2017 AWS WAF
Amazon Web Services Japan
 
PDF
20190911 AWS Black Belt Online Seminar AWS Batch
Amazon Web Services Japan
 
PDF
20190129 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...
Amazon Web Services Japan
 
PDF
20201111 AWS Black Belt Online Seminar AWS CodeStar & AWS CodePipeline
Amazon Web Services Japan
 
PDF
DevOps with Database on AWS
Amazon Web Services Japan
 
20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用
Amazon Web Services Japan
 
AWS Black Belt Online Seminar 2018 Amazon DynamoDB Advanced Design Pattern
Amazon Web Services Japan
 
20201028 AWS Black Belt Online Seminar Amazon CloudFront deep dive
Amazon Web Services Japan
 
20200630 AWS Black Belt Online Seminar Amazon Cognito
Amazon Web Services Japan
 
AWS Black Belt Online Seminar Amazon Aurora
Amazon Web Services Japan
 
20200826 AWS Black Belt Online Seminar AWS CloudFormation
Amazon Web Services Japan
 
20190730 AWS Black Belt Online Seminar Amazon CloudFrontの概要
Amazon Web Services Japan
 
AWS Black Belt Online Seminar 2017 Amazon ElastiCache
Amazon Web Services Japan
 
20191029 AWS Black Belt Online Seminar Elastic Load Balancing (ELB)
Amazon Web Services Japan
 
Amazon Simple Workflow Service (SWF)
Amazon Web Services Japan
 
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
Amazon Web Services Japan
 
AWS Black Belt Online Seminar 2016 AWS CloudFormation
Amazon Web Services Japan
 
20190226 AWS Black Belt Online Seminar Amazon WorkSpaces
Amazon Web Services Japan
 
AWS Black Belt Online Seminar 2016 AWS上でのActive Directory構築
Amazon Web Services Japan
 
20190319 AWS Black Belt Online Seminar Amazon FSx for Windows Server
Amazon Web Services Japan
 
AWS Black Belt Online Seminar 2017 AWS WAF
Amazon Web Services Japan
 
20190911 AWS Black Belt Online Seminar AWS Batch
Amazon Web Services Japan
 
20190129 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...
Amazon Web Services Japan
 
20201111 AWS Black Belt Online Seminar AWS CodeStar & AWS CodePipeline
Amazon Web Services Japan
 
DevOps with Database on AWS
Amazon Web Services Japan
 
Ad

Similar to 20200526 AWS Black Belt Online Seminar AWS X-Ray (20)

PDF
20210127 今日から始めるイベントドリブンアーキテクチャ AWS Expert Online #13
Amazon Web Services Japan
 
PDF
20200804 AWS Black Belt Online Seminar Amazon CodeGuru
Amazon Web Services Japan
 
PDF
20200218 AWS Black Belt Online Seminar Next Generation Redshift
Amazon Web Services Japan
 
PDF
20191218 AWS Black Belt Online Seminar AWSのマネジメント&ガバナンス サービスアップデート
Amazon Web Services Japan
 
PDF
20190312 AWS Black Belt Online Seminar AWS Well-Architected Frameworkによるコスト最適化
Amazon Web Services Japan
 
PDF
20200623 AWS Black Belt Online Seminar Amazon Elasticsearch Service
Amazon Web Services Japan
 
PDF
20200212 AWS Black Belt Online Seminar AWS Systems Manager
Amazon Web Services Japan
 
PDF
20190821 AWS Black Belt Online Seminar AWS AppSync
Amazon Web Services Japan
 
PDF
20200128 AWS Black Belt Online Seminar Amazon Forecast
Amazon Web Services Japan
 
PDF
20190522 AWS Black Belt Online Seminar AWS Step Functions
Amazon Web Services Japan
 
PDF
20200714 AWS Black Belt Online Seminar Amazon Neptune
Amazon Web Services Japan
 
PDF
20180801 AWS Black Belt Online Seminar Amazon QuickSight アップデート
Amazon Web Services Japan
 
PDF
20200205 AWSの16あるデータベースを使いこなそう
Amazon Web Services Japan
 
PDF
20200930 AWS Black Belt Online Seminar Amazon Kinesis Video Streams
Amazon Web Services Japan
 
PDF
Sapporo devfesta 2019/11/13
Kameda Harunobu
 
PDF
20200721 AWS Black Belt Online Seminar AWS App Mesh
Amazon Web Services Japan
 
PPTX
Deep Dive: AWS X-Ray London Summit 2017
Randall Hunt
 
PPTX
Fin jaws 202103
Yuki Yoshida
 
PDF
20190319 AWS Black Belt Online Seminar Amazon FSx for Lustre
Amazon Web Services Japan
 
PDF
Aws-What You Need to Know_Simon Elisha
Helen Rogers
 
20210127 今日から始めるイベントドリブンアーキテクチャ AWS Expert Online #13
Amazon Web Services Japan
 
20200804 AWS Black Belt Online Seminar Amazon CodeGuru
Amazon Web Services Japan
 
20200218 AWS Black Belt Online Seminar Next Generation Redshift
Amazon Web Services Japan
 
20191218 AWS Black Belt Online Seminar AWSのマネジメント&ガバナンス サービスアップデート
Amazon Web Services Japan
 
20190312 AWS Black Belt Online Seminar AWS Well-Architected Frameworkによるコスト最適化
Amazon Web Services Japan
 
20200623 AWS Black Belt Online Seminar Amazon Elasticsearch Service
Amazon Web Services Japan
 
20200212 AWS Black Belt Online Seminar AWS Systems Manager
Amazon Web Services Japan
 
20190821 AWS Black Belt Online Seminar AWS AppSync
Amazon Web Services Japan
 
20200128 AWS Black Belt Online Seminar Amazon Forecast
Amazon Web Services Japan
 
20190522 AWS Black Belt Online Seminar AWS Step Functions
Amazon Web Services Japan
 
20200714 AWS Black Belt Online Seminar Amazon Neptune
Amazon Web Services Japan
 
20180801 AWS Black Belt Online Seminar Amazon QuickSight アップデート
Amazon Web Services Japan
 
20200205 AWSの16あるデータベースを使いこなそう
Amazon Web Services Japan
 
20200930 AWS Black Belt Online Seminar Amazon Kinesis Video Streams
Amazon Web Services Japan
 
Sapporo devfesta 2019/11/13
Kameda Harunobu
 
20200721 AWS Black Belt Online Seminar AWS App Mesh
Amazon Web Services Japan
 
Deep Dive: AWS X-Ray London Summit 2017
Randall Hunt
 
Fin jaws 202103
Yuki Yoshida
 
20190319 AWS Black Belt Online Seminar Amazon FSx for Lustre
Amazon Web Services Japan
 
Aws-What You Need to Know_Simon Elisha
Helen Rogers
 
Ad

More from Amazon Web Services Japan (20)

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

Recently uploaded (20)

PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Doc9.....................................
SofiaCollazos
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 

20200526 AWS Black Belt Online Seminar AWS X-Ray

  • 1. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS 公式 Webinar https://amzn.to/JPWebinar 過去資料 https://amzn.to/JPArchive Solutions Architect 鈴木 太一郎 2020/5/26 AWS X-Ray サービスカットシリーズ [AWS Black Belt Online Seminar]
  • 2. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 自己紹介 鈴木 太一郎 所属 • アマゾン ウェブ サービス ジャパン株式会社 技術統括本部 • ソリューションアーキテクト 好きなサービス • AWS X-Ray • AWS CDK
  • 3. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Black Belt Online Seminar とは 「サービス別」「ソリューション別」「業種別」のそれぞれのテーマに分かれて、アマゾ ン ウェブ サービス ジャパン株式会社が主催するオンラインセミナーシリーズです。 質問を投げることができます! • 書き込んだ質問は、主催者にしか見えません • 今後のロードマップに関するご質問は お答えできませんのでご了承下さい ① 吹き出しをクリック ② 質問を入力 ③ Sendをクリック Twitter ハッシュタグは以下をご利用ください #awsblackbelt
  • 4. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 内容についての注意点 • 本資料では2020年5月26日時点のサービス内容および価格についてご説明しています。最新の 情報はAWS公式ウェブサイト(http://aws.amazon.com)にてご確認ください。 • 資料作成には十分注意しておりますが、資料内の価格とAWS公式ウェブサイト記載の価格に相 違があった場合、AWS公式ウェブサイトの価格を優先とさせていただきます。 • 価格は税抜表記となっています。日本居住者のお客様には別途消費税をご請求させていただきま す。 • AWS does not offer binding price quotes. AWS pricing is publicly available and is subject to change in accordance with the AWS Customer Agreement available at http://aws.amazon.com/agreement/. Any pricing information included in this document is provided only as an estimate of usage charges for AWS services based on certain information that you have provided. Monthly charges will be based on your actual use of AWS services, and may vary from the estimates provided.
  • 5. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. アジェンダ • AWS X-Ray とは • AWS X-Ray の概念 • AWS X-Ray によるアプリケーション分析 • AWS X-Ray によるデータ収集の仕組み • AWS X-Ray の利用方法 • Amazon CloudWatch との連携 • 料金・注意点 • まとめ
  • 6. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. アジェンダ • AWS X-Ray とは • AWS X-Ray の概念 • AWS X-Ray によるアプリケーション分析 • AWS X-Ray によるデータ収集の仕組み • AWS X-Ray の利用方法 • Amazon CloudWatch との連携 • 料金・注意点 • まとめ
  • 7. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • モノリシック アプリケーション  多数の機能を1プロセスで稼働 • マイクロサービス アプリケーション  少数のまとまった機能を持つ複数のサービスで構成  各サービスが独立したプロセスとして稼働  サーバレスやコンテナと相性が良い モノリシック vs マイクロサービス
  • 8. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. モノリシック vs マイクロサービス • モノリシック アプリケーション  大規模アプリでは、高速なイテレーションが難しい  効率的なスケールが難しい  不具合や障害が全体に影響 • マイクロサービス アプリケーション  各サービスで独立した開発・デプロイ  各サービスで独立したスケーリング  障害の直接的な影響が各サービス内
  • 9. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マイクロサービスにおける障害対応・パフォーマンス分析 • 障害発生時の原因究明 • ログが分散・それぞれ独自のフォーマット • 依存しあう多数の多様なサービス群 • パフォーマンス分析が難しい • ボトルネックのサービスはどこなのか • 日々変化するサービス間の依存関係と全体像
  • 10. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray の概要 アプリケーションやその基盤となるサービスの実行状況を把握し パフォーマンスの問題やエラーの根本原因を特定する
  • 11. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray の概要 アプリケーションやその基盤となるサービスの実行状況を把握し パフォーマンスの問題やエラーの根本原因を特定する
  • 12. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray の概要 アプリケーションやその基盤となるサービスの実行状況を把握し パフォーマンスの問題やエラーの根本原因を特定する
  • 13. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray の概要 アプリケーションやその基盤となるサービスの実行状況を把握し パフォーマンスの問題やエラーの根本原因を特定する
  • 14. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray のメリット リクエスト実行状況の確認 アプリケーションを構成する 個々のサービスやリソースの 実行結果ステータスを集計し、 アプリケーションの実行状況を End-to-End で確認可能 アプリケーションの問題の検出 アプリケーションの実行状況に ついての関連する情報を収集し、 問題の根本原因を調査可能 アプリケーションのパフォーマンス向上 サービスやリソースの関係をリアルタイムで 表示し、レイテンシ増加やパフォーマンス低下 などのボトルネックを特定可能 AWSとの連携 Amazon EC2, Amazon ECS, AWS Lambda, AWS Elastic Beanstalk などと連携 さまざまなアプリケーション向けの設計 非同期のシンプルなイベント呼び出し、 3層のウェブアプリケーション、数千の サービスから構成される複雑なマイクロ サービスも分析可能
  • 15. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. アジェンダ • AWS X-Ray とは • AWS X-Ray の概念 • AWS X-Ray によるアプリケーション分析 • AWS X-Ray によるデータ収集の仕組み • AWS X-Ray の利用方法 • Amazon CloudWatch との連携 • 料金・注意点 • まとめ
  • 16. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray の概念 AWS Lambda Amazon DynamoDB AWS Lambda が Amazon DynamoDB を3回呼び出し
  • 17. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray の概念 セグメント 動作に関するデータ • リソース名 • リクエストの詳細 • 行った作業の詳細 Amazon DynamoDB AWS Lambda
  • 18. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray の概念 セグメント サブセグメント 呼び出しに関する追加の詳細な情報 • AWS のサービス • 外部 HTTP API • SQL データベース • など Amazon DynamoDB AWS Lambda
  • 19. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray の概念 セグメント Amazon API Gateway Amazon API Gateway AWS Fargate Amazon S3 エンドユーザー サブセグメント Amazon DynamoDB AWS Lambda
  • 20. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray の概念 セグメント エンドユーザー トレース サブセグメント 1つのリクエストで生成されたセグメントの全てを収集したもの Amazon DynamoDB AWS Lambda Amazon S3 Amazon API Gateway Amazon API Gateway AWS Fargate
  • 21. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. セグメント Lambda DynamoDB API Gateway API Gateway Fargate S3 エンドユーザー トレース サブセグメント • どのようにトレースが含むセグメントを管理している? • セグメントのつながり・順序はどう管理している? AWS X-Ray の概念
  • 22. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray の概念 どのようにトレースが含むセグメントを管理している? • トレース ID • リクエストを追跡するための ID • リクエストごとに一意 • 基本的に最初にセグメントを生成するタイミングで生成 セグメント トレース ID (B) セグメント トレース ID (B) セグメント トレース ID (A) トレース (B) セグメント トレース ID (B) セグメント トレース ID (B) トレース (A) セグメント トレース ID (A) セグメント トレース ID (A) AWS LambdaAmazon API Gatway セグメント トレース ID (A)
  • 23. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray の概念 セグメントのつながり・順序はどう管理している? • セグメント ID • トレース内のセグメントに対して一意に決まる • 単一のサービスのリクエストを追跡するための ID • 親セグメント ID によってセグメントのつながり・順序が決まる セグメント (A) 親セグメント ID (B) セグメント (C) 親セグメント ID (A) セグメント (B) セグメント (A) 親セグメント ID (B) セグメント (C) 親セグメント ID (A) セグメント (B) トレース トレース リクエストの流れ
  • 24. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray の概念 セグメント同士のつながりや順序はどう管理している? • セグメント ID • 単一のサービスのリクエストを追跡するためのID • 親セグメント ID によってセグメントのつながりが決まる セグメント 親セグメント ID セグメント 親セグメント ID セグメント セグメント 親セグメント ID セグメント 親セグメント ID セグメント トレース トレース トレース ID や セグメント ID をどう伝搬している?
  • 25. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. X-Amzn-Trace-Id: Root=1- 57…93;Parent=53…d8;Sampled=1 AWS X-Ray の概念 トレース ID や セグメント ID をどう伝搬している? • トレースヘッダー • トレース ID、親セグメントID、サンプリングデシジョンが定義された HTTP ヘッダー トレース ID 親セグメント ID サンプルデシジョン サンプリング対象か否か (1=true, 0=false)
  • 26. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray の概念 セグメントに情報を追加したい 検索しやすくするため • 注釈 • フィルタ式 (後述) で使用するためインデックス化されたキーと値のペ ア • 例 "aws:api_stage": "prod" デバッグや分析のため • メタデータ • 任意のタイプの値を持つことができるキーと値のペア • フィルタ式で使用するためのインデックスは作成されない • 例 "game": {"id": "abcdefg", "session": "xxxyyyzzz"}
  • 27. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. アジェンダ • AWS X-Ray とは • AWS X-Ray の概念 • AWS X-Ray によるアプリケーション分析 • AWS X-Ray によるデータ収集の仕組み • AWS X-Ray の利用方法 • Amazon CloudWatch との連携 • 料金・注意点 • まとめ
  • 28. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray によるアプリケーション分析 サービスマップ トレースデータの可視化 トレースリスト トレースの詳細な情報 アナリティクス トレース分析用ツール 特定のサービスに関連する トレースリストの確認 特定のサービスに関連する トレースリストを分析 分析対象のトレースリストの 詳細を確認 End-to-End のリクエストの確認
  • 29. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. サービスマップ • 読み取れる情報 • フィルタ式 • グループ サービスマップ トレースリスト アナリティクス
  • 30. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. サービスマップ
  • 31. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. サービスマップ • 成功した呼び出し • 4xx エラー • 5xx エラー • スロットリングエラー 平均レイテンシ (ms) トレース数 (trace/min) サービス名 サービスの分類
  • 32. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. サービスマップ クリック アナリティクス トレースリスト
  • 33. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. フィルタ式 • トレースを絞り込むための機能 • トレースリストとアナリティクスで利用可能 • duration >= 5 AND duration <= 8 総所要時間 が5秒〜8秒 • http.status != 200 レスポンスステータスが 200 OK ではない • service(name) { filter } 特定のサービスを含んだリクエスト • edge(source, destination) { filter } 特定のサービス間の接続 https://docs.aws.amazon.com/ja_jp/xray/latest/devguide/xray-console- filters.html
  • 34. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • トレースを絞り込むための機能 • トレースリストとアナリティクスで利用可能 • duration >= 5 AND duration <= 8 総所要時間 が5秒〜8秒 • http.status != 200 レスポンスステータスが 200 OK ではない • service(name) { filter } 特定のサービスを含んだリクエスト • edge(source, destination) { filter } 特定のサービス間の接続 フィルタ式 https://docs.aws.amazon.com/ja_jp/xray/latest/devguide/xray-console- filters.html クリック クリック
  • 35. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • グループ • フィルタ式で定義されるトレースのコレクション • サービスマップ、トレースリスト、アナリティクスで利用可能 • Amazon CloudWatch にメトリクスを作成 (トレース数) グループ https://docs.aws.amazon.com/ja_jp/xray/latest/devguide/xray-console- filters.html
  • 36. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. トレースリスト • トレースリスト • セグメント・サブセグメント • カスタムサブセグメント • セグメント詳細 サービスマップ トレースリスト アナリティクス
  • 37. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. トレースリスト トレースリスト URL
  • 38. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. トレースリスト クリック
  • 39. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. セグメント・サブセグメント セグメント サブセグメント
  • 40. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. カスタムサブセグメント カスタムサブセグメント 監視・計測したい機能ごとにサブセグメントとして切り出すことが可能
  • 41. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. セグメント詳細 クリック
  • 42. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. セグメント詳細
  • 43. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. セグメント詳細 概要 注釈 例外 リソース メタデータ セグメント情報 時間情報 エラー情報 リクエスト レスポンス詳細
  • 44. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. アナリティクス • フィルタリングされたトレースセット • 応答時間の分布 • 時系列アクティビティ • メトリクステーブル • ワークルフローの例 サービスマップ トレースリスト アナリティクス
  • 45. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. フィルタリングされたトレースセット • グラフやテーブルに対して操作を行いアナリティクス内に作成 • 最大で2つ ( A と B ) まで作成可能 • トレースセットを活用することで素早い分析が可能 グラフに対してドラッグ テーブルに対して選択 全てのトレース グループ フィルタリングの結果 フィルタリングされたトレースセット A フィルタリングされたトレースセット B アナリティクスで可視化されるトレース
  • 46. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 応答時間の分布 • 指定された応答時間におけるトレース数を示すグラフ • 横軸 応答時間 • 縦軸 トレース数 • ドラッグすることで フィルタリングされたトレースセット を作成できる ドラッグ
  • 47. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • 指定された時間のトレース数 • 横軸 時間 • 濃さ トレース数 (濃い方が多い) • ドラッグすることで フィルタリングされたトレースセット を作成できる 時系列アクティビティ ドラッグ
  • 48. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • Http Status Code や Response Time Root Cause など事前に定義された属性に 基づき分類されたトレース • テーブルの行をクリックすることでフィルタリングされたトレースセット として設定可能 メトリクステーブル クリック
  • 49. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • テーブルの属性は変更可能 • 注釈も指定できる メトリクステーブル クリック
  • 50. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. アナリティクスを用いたワークフローの例 1. リリースが応答時間に影響を与えていないか確認 • リリースした機能によってパフーマンスが悪化した場合 • パフォーマンス改善のリリースが効果的か調べる場合 2. 応答時間と時間帯に相関があるか調べる • サービスの負荷が高まる時間帯に応答時間が長くなっていないか調べる場合
  • 51. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ワークフローの例 ① リリースが応答時間に影響を与えていないか確認したい
  • 52. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ワークフローの例 ① リリースが応答時間に影響を与えていないか確認したい 時系列アクティビティにてリリース後の期間をドラッグし フィルタリングされたトレースセット A を作成 ドラッグ リリースしたタイミング
  • 53. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ワークフローの例 ① リリースが応答時間に影響を与えていないか確認したい 応答時間の分布を確認し応答時間に影響がないことを確認 偏りがない
  • 54. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ワークフローの例 ① リリースが応答時間に影響を与えていないか確認したい Http Status Code のテーブルを確認すれば リリースがエラーを起こしていないか確認できる
  • 55. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ワークフローの例 ② 応答時間と時間帯に相関があるか調べる
  • 56. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ワークフローの例 ② 応答時間と時間帯に相関があるか調べる 応答時間の早い トレースセット A を作成 ドラッグ
  • 57. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ワークフローの例 ② 応答時間と時間帯に相関があるか調べる 応答時間の遅い トレースセット B を作成 ドラッグ
  • 58. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ワークフローの例 ② 応答時間と時間帯に相関があるか調べる 時系列アクティビティを確認し 分布に偏りがないことから時間との相関はないと判断 偏りがない
  • 59. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. サンプリング • サンプリングとは • サンプリングの作成 • ルール名・優先度 • リザーバサイズ・固定レート • 一致基準
  • 60. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. サンプリングとは • AWS X-Ray ではサンプリングルールに従い記録されるリクエストが決まる • デフォルトのサンプリングルール • 1秒ごとに最初のリクエストは必ずトレースされる • それ以降のリクエストについては全体の5%がトレースされる • なぜサンプリングが必要? • 課金額のコントロール • パフォーマンスへの影響をコントロール • 設定方法 • コンソール • ローカルルール ( SDK から設定を読み込む ) 今からご紹介
  • 61. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. サンプリングの作成
  • 62. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. サンプリングの作成 全ての条件に一致 ルールが適応されたトレース数
  • 63. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. サンプリングの作成 クリック
  • 64. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ルール名・優先度 値が低い方が優先的に適応 デフォルトのルールは10000
  • 65. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. リザーバサイズ・固定レート デフォルトはリザーバサイズ= 1 固定レート=5% • リザーバサイズ 1秒間で必ず記録するトレース数 • 固定レート リザーバサイズを超えたリクエスト数のうち何%を記録するか リザーバサイズ=50 固定レート=10% 1秒あたり100件のリクエストがルールに一致する場合 50 (リザーバーサイズ) + 50 x 0.1 (固定レート) = 55 リクエスト 例
  • 66. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 一致基準 例: AWS::APIGateway::Stage 例: POST 例: /api/ 例: arn:aws:execute-api… 例: webserver.mydomain.com 例: MyApplication
  • 67. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. アジェンダ • AWS X-Ray とは • AWS X-Ray の概念 • AWS X-Ray によるアプリケーション分析 • AWS X-Ray によるデータ収集の仕組み • AWS X-Ray の利用方法 • Amazon CloudWatch との連携 • 料金・注意点 • まとめ
  • 68. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray のデータ収集の仕組み スクリプトやツール AWS SDK AWS CLI AWS X-Ray SDK アプリケーション AWS X-Ray API AWS X-Ray コンソール AWS X-Ray デーモン
  • 69. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray のデータ収集の仕組み スクリプトやツール AWS SDK AWS CLI AWS X-Ray SDK アプリケーション AWS X-Ray API AWS X-Ray コンソール AWS X-Ray デーモン アプリケーションで作成したセグメントデータを X-Ray デーモンに送信
  • 70. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray SDK Java Node.js .Net Ruby Go Python • トレースデータを作成して X-Ray デーモンに送信するた めのクラスとメソッドを提供 • 受信リクエスト • AWS SDK クライアント (Amazon DynamoDB, Amazon S3, …) • 送信 HTTP 呼び出し • SQL クエリ • カスタムサブセグメント • … AWSX-Ray SDK アプリケーション
  • 71. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray のデータ収集の仕組み スクリプトやツール AWS SDK AWS CLI AWS X-Ray SDK アプリケーション AWS X-Ray API AWS X-Ray コンソール AWS X-Ray デーモン X-Ray デーモンはセグメントデータを バッファリングし X-Ray API に定期的に転送
  • 72. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray デーモン • 未加工のセグメントデータを収集して AWS X-Ray API に送信 • UDP ポート 2000 (デフォルト) をリッスン • 受信したデータをバッファリングして X-Ray API に送信する • 実行方法 • Linux 実行可能ファイル, RPMパッケージ, DEBパッケージ • OS X 実行可能ファイル • Windows 実行可能ファイル, サービス • AWS Lambda コンソールから設定 • AWS Elastic Beanstalk コンソールから設定 • Amazon ECS Sidecar として実行 AWS X-Ray デーモン
  • 73. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray のデータ収集の仕組み スクリプトやツール AWS SDK AWS CLI AWS X-Ray SDK アプリケーション AWS X-Ray API AWS X-Ray コンソール AWS X-Ray デーモン 収集されたセグメントデータから トレースを作成
  • 74. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray のデータ収集の仕組み スクリプトやツール AWS SDK AWS CLI AWS X-Ray SDK アプリケーション AWS X-Ray API AWS X-Ray コンソール AWS X-Ray デーモン X-Ray SDK を使わずに直接 X-Ray API と データのやり取りをすることも可能
  • 75. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray API • AWS X-Ray の全ての機能にアクセス可能 • トレースの追加・取得・更新 • グループの作成・取得・更新・削除 • サンプリングルールの作成・取得・更新・削除 • 利用方法 • HTTPS 経由 • AWS SDK 経由 • AWS Command Line Interface 経由 AWS X-Ray API
  • 76. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray のデータ収集の仕組み スクリプトやツール AWS SDK AWS CLI AWS X-Ray SDK アプリケーション AWS X-Ray API AWS X-Ray コンソール AWS X-Ray デーモン トレースをコンソールで可視化 分析・デバッグを行う
  • 77. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. アジェンダ • AWS X-Ray とは • AWS X-Ray の概念 • AWS X-Ray によるアプリケーション分析 • AWS X-Ray によるデータ収集の仕組み • AWS X-Ray の利用方法 • Amazon CloudWatch との連携 • 料金・注意点 • まとめ
  • 78. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambda • トレースの有効化は AWS Lambda 関数の設定から • 多少のメモリ消費量の増加あり • HTTP 呼び出し・注釈・メタデータの追加などには AWS X-Ray SDK が必要
  • 79. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon API Gateway • ステージの設定から X-Ray トレースの有効化 • HTTP リクエストにトレースヘッダーを追加 • AWS X-Ray コンソールで定義したサンプリングルール
  • 80. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Elastic Beanstalk • ソフトウェアから AWS X-Ray を有効化 • アプリケーションに AWS X-Ray SDK を組み込む作業は必要
  • 81. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon EC2 • X-Ray デーモンが実行可能な OS • Amazon Linux • Ubuntu • Windows Server (2012 R2 以降) • インスタンス起動時にユーザーデータのスクリプトを実行してデーモンを起動 #!/bin/bash curl https://s3.dualstack.us-east- 2.amazonaws.com/aws-xray-assets.us-east-2/xray- daemon/aws-xray-daemon-3.x.rpm -o /home/ec2- user/xray.rpm yum install -y /home/ec2-user/xray.rpm Amazon Linux の例
  • 82. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • AWS X-Ray デーモンの Docker コンテナを Sidecar として設定 • ネットワークモードによってコンテナ周りのタスク定義の設定が異なる • ブリッジ (デフォルト) リンクを作成し 環境変数 AWS_XRAY_DAEMON_ADDRESS に向き 先を設定 • awsvpc 特に設定は必要ない { "name": "xray-daemon", "image": "amazon/aws-xray- daemon", "cpu": 32, "memoryReservation": 256, "portMappings" : [ { "hostPort": 0, "containerPort": 2000, "protocol": "udp" } ], } AWS X-Ray デーモン AWS X-Ray API アプリケーション AWS X-Ray SDK Amazon ECS タスク AWS X-Ray デーモン アプリケーション AWS X-Ray SDK Amazon ECS タスク Amazon ECS
  • 83. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS App Mesh • AWS App Mesh の Envoy プロキシに環境変数 ENABLE_ENVOY_XRAY_TRACING: ”1”に設定するこ とで AWS X-Ray デーモン (127.0.0.1:2000) にデータを転送 • AWS AppMeshが動作している環境に応じて AWS X-Ray デーモンの設定が必要 AWS X-Ray デーモン AWS X-Ray API アプリケーション AWS X-Ray SDK Amazon ECS タスク AWS App Mesh Sidecar AWS X-Ray デーモン アプリケーション AWS X-Ray SDK Amazon ECS タスク AWS App Mesh Sidecar Amazon ECS の例
  • 84. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon SQS, Amazon SNS • Amazon SQS と Amazon SNS とも統合 • 統合を有効化する設定は必要ない パッシブ計測 別のサービスですでにサンプリングされているリクエストを計測 Amazon SQS, Amazon SNS アクティブ計測 受信リクエストをサンプリングして計測 Amazon API Gateway, AWS Lambda *)Amazon API Gateway と AWS Lambda はパッシブ計測も可能 パッシブ計測 AWS Lambda Amazon SQS コンシューマー Amazon SQS の例
  • 85. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS SAM, CDK • AWS SAM, CDK から X-Ray の有効化が可能 Type: AWS::Serverless::Function Properties: FunctionName: MyFunction Handler: index.handler Tracing: Active ... const myFunction = new lambda.Function(this, 'myFunction', { functionName: 'MyFunction', handler: 'index.handler', tracing: lambda.Tracing.ACTIVE, ... }); AWS SAM CDK (Typescript) AWS Lambda の例
  • 86. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray SDK (Node.js) • 受信リクエストのトレース ( express の例 ) const app = express(); const AWSXRay = require('aws-xray-sdk'); app.use(AWSXRay.express.openSegment('MyAp p')); app.get('/', function (req, res) { res.render('index'); }); app.use(AWSXRay.express.closeSegment()); const AWSXRay = require('aws-xray-sdk'); AWSXRay.captureHTTPsGlobal(require('http’)); AWSXRay.capturePromise(); // request-promise, axios 利用時 // http を利用する場合 const http = require('http’); // request を利用する場合 const request = require('request’); // axios を利用する場合 const axios = require('axios’); • HTTPリクエストのトレース
  • 87. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray SDK (Node.js) • AWS サービス呼び出しのトレース • カスタムサブセグメントの生成 const AWS = AWSXRay.captureAWS(require('aws- sdk')); const s3 = new AWS.S3(); // s3 を利用した呼び出しはトレースされる const AWSXRay = require('aws-xray-sdk'); AWSXRay.captureFunc('SubSegment1', (subsegment) => { console.log('hello!'); }); AWSXRay.captureAsyncFunc('SubSegment2', (subsegment) => { setTimeout(() => { subsegment.close() }, 1000); });
  • 88. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. アジェンダ • AWS X-Ray とは • AWS X-Ray の概念 • AWS X-Ray によるアプリケーション分析 • AWS X-Ray によるデータ収集の仕組み • AWS X-Ray の利用方法 • Amazon CloudWatch との連携 • 料金・注意点 • まとめ
  • 89. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon CloudWatch ServiceLens • Amazon CloudWatch と AWS X-Ray を統合 • トレース • メトリクス • ログ • アラート AWS X-Ray のデータを利用 サービスマップ メトリクスグラフ、アラート Amazon CloudWatch Logs インサイト トレースの一覧やフィルタリング機能 メトリクスの詳細やノードマップ
  • 90. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon CloudWatch Synthetics • Canaryを作成してエンドポイントを監視 • Canaryとは • 特定のエンドポイントにアクセス • 定期的なスケジュールで実行 • ロード時間データとUIのスクリーンショットを保存 • 閾値によってアラームを作成 Canary実行 サービスマップ • Amazon CloudWatch ServiceLens、AWS X-Ray と統合
  • 91. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. アジェンダ • AWS X-Ray とは • AWS X-Ray の概念 • AWS X-Ray によるアプリケーション分析 • AWS X-Ray によるデータ収集の仕組み • AWS X-Ray の利用方法 • Amazon CloudWatch との連携 • 料金・注意点 • まとめ
  • 92. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 料金 (2020/5/26 現在) • 記録、取得、スキャンされたトレースの数に基づいて料金が発生 • 永続的な無料利用枠 • 毎月 トレースの記録は 10 万回まで無料 • 毎月 トレースの取得とスキャンは合わせて 100 万回まで無料 トレースの記録 100 万件あたり 5.00USD トレースの取得 100 万件あたり 0.50USD トレースのスキャン 100 万件あたり 0.50USD * 無料利用枠を超えた分 * リージョン アジアパシフィック (東京) https://aws.amazon.com/xray/pricing/
  • 93. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 注意点 • サンプリングについて • デフォルトではサンプリングされる • 100% トレースする設定も可能だが、料金とパフォーマンスへの影響 を事前に確認する • データの完全性は保証されない • 監査やコンプライアンスのツールとして使用することはできない • 直近 30 日間の追跡データが保存 • 過去 30 日間の追跡データに対してクエリを実行可能
  • 94. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. アジェンダ • AWS X-Ray とは • AWS X-Ray の概念 • AWS X-Ray によるアプリケーション分析 • AWS X-Ray によるデータ収集の仕組み • AWS X-Ray の利用方法 • Amazon CloudWatch との連携 • 料金・注意点 • まとめ
  • 95. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. まとめ AWS X-Ray 有用なツール群 • サービスマップ マイクロサービスアプリケーションにおいて把握が難しい サービス間の依存関係をわかりやすく可視化 • トレースリスト 詳細なトレースデータにアクセス可能 セグメントやサブセグメントの実行状況を可視化 • アナリティクス インタラクティブな操作によって素早い分析が可能 利用の容易さ  AWS X-Ray SDK や AWS X-Ray デーモンによってアプリケーションに簡単に組み込める  多くの AWS サービスと統合されていて簡単にセットアップ可能
  • 96. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Q&A お答えできなかったご質問については AWS Japan Blog 「https://aws.amazon.com/jp/blogs/news/」にて 後日掲載します。
  • 97. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS の日本語資料の場所「AWS 資料」で検索 https://amzn.to/JPArchive
  • 98. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. で[検索]AWS イベント 毎週”W-A個別技術相談会”を実施中 • AWSのソリューションアーキテクト(SA)に 対策などを相談することも可能 • 申込みはイベント告知サイトから (https://aws.amazon.com/jp/about-aws/events/) AWS Well-Architected 個別技術相談会
  • 99. © 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS 公式 Webinar https://amzn.to/JPWebinar 過去資料 https://amzn.to/JPArchive ご視聴ありがとうございました