Game Analytics Pipeline (遊戲服務監控與分析)
- 作者 -
Howard Hsiung, Territory Business Development Manager, AWS
David Hung, Technical Program Intern, AWS

[挑戰/適用場景]
遊戲分析管道解決方案可協助遊戲開發人員啟動可擴展的無伺服器資料管道,以擷取從遊戲和服務中產生的遙測資料,並進行儲存和分析。該解決方案支援串流擷取資料,可讓使用者在數分鐘內從其遊戲和其他應用程式取得洞見。該解決方案提供 REST API 和 Amazon Kinesis 服務,用於擷取和處理遊戲遙測。它還自動驗證、轉換並以最佳化的格式傳遞資料給 Amazon Simple Storage Service (Amazon S3),以進行經濟高效的儲存和分析。該解決方案透過在 Amazon S3 中組織和結構化資料,並設定 AWS Glue 針對資料集對中繼資料编目,可讓您輕鬆與其他應用程式和使用者整合和共用資料。
這項解決方案設計用於提供將遊戲活動擷取到資料湖進行分析和儲存的架構,可讓您專注於擴充解決方案的功能,而非將時間花在管理底層基礎架構的運作上。

遊戲分析管道解決方案架構
AWS CloudFormation 範本部署 AWS 資源,以啟用遊戲分析資料擷取、分析、監控和報告,設定基礎架構來支援無伺服器資料管道。Amazon API Gateway 提供 REST API 端點,用於在解決方案中註冊遊戲應用程式及擷取遊戲遙測資料,這會將事件傳送至 Amazon Kinesis Data Streams。Amazon DynamoDB 儲存遊戲應用程式組態和 API 金鑰。
Kinesis Data Streams 擷取來自資料生產者的串流遊戲資料,包括遊戲用戶端、遊戲伺服器和其他應用程式,並透過 Amazon Kinesis Data Firehose 和 Amazon Kinesis Data Analytics 啟用即時資料處理。Kinesis Data Firehose 消耗來自 Kinesis Data Streams 的串流資料,並透過批次事件叫用 AWS Lambda,進行無伺服器資料處理和轉換,然後再擷取至 Amazon Simple Storage Service (Amazon S3) 進行儲存。
AWS Glue 在 AWS Glue 資料型錄中提供擷取、轉換和載入 (ETL) 處理工作流程和中繼資料儲存,這為資料湖整合靈活的分析工具提供了基礎。範例 Amazon Athena 查詢可分析遊戲事件,並與 Amazon QuickSight 整合以產生報告和視覺化。Amazon CloudWatch 監控、記錄並產生有關 AWS 資源使用率的警示,並建立可操作的儀表板。Amazon Simple Notification Service (Amazon SNS) 在觸發 CloudWatch 警示時,向解決方案管理員和其他資料使用者傳遞通知。
[操作步驟]
步驟一 | 執行 AWS CloudFormation 範本 |
步驟二 | 透過 AWS Cloud 9 發送測試資料 |
步驟三 | 透過 Amazon Athena產生 SQL View |
步驟四 | 透過 Amazon CloudWatch 即時監控 |
步驟五 | 透過 Amazon Quicksight 進行資料視覺化 |
步驟一、執行 AWS CloudFormation 範本
▍ 1.1
首先透過此連結直接導向 AWS Console 登入介面,登入AWS帳戶後即進入CloudFormation 範本部署介面:

▍ 1.2

▍ 1.3

▍ 1.4

▍ 1.5

步驟二、透過 AWS Cloud 9 發送測試資料
▍ 2.1

▍ 2.2

▍ 2.3
git clone https://github.com/awslabs/game-analytics-pipeline
cd game-analytics-pipeline/source/demo/
python3 -m pip install --user —upgrade pip
python3 -m pip install —user virtualenv
python3 -m venv env
source env/bin/activate
pip install boto3 numpy uuid argparse

python3 publish_data.py --region <aws-region> --stream-name <GameEventsStream> --application-id <TestApplicationId>

步驟三、透過 Amazon Athena產生 SQL View:
▍ 3.1
CREATE OR REPLACE VIEW win_spell AS
SELECT
*
, "json_extract_scalar"("event_data", '$.most_used_weapon') "spell_id"
, "json_extract_scalar"("event_data", '$.map_id') "map_id"
FROM
raw_events
WHERE "json_extract_scalar" ("event_data", '$.match_result_type') = 'WIN'

步驟四、透過 Amazon CloudWatch 即時監控
▍ 4.1



步驟五、透過 Amazon Quicksight 進行資料視覺化
▍ 5.1
前往 Amazon Quicksight 控制面板,點選右上角的 Manage Quicksight ,並選擇 Security & permissions 進入權限設定頁面,完成後按下 Finish 以及 Update 更新設定。

▍ 5.2


▍ 5.3



▍ 5.4

[常見問題]
Q1: Quicksight 產生的資料圖表是即時的嗎?
A1: Quicksight 的資料需要進行重新整理才會更新,目前可以透過手動或排程的方式進行,詳細資訊可訪問 QuickSight 官方使用手冊。
Q2: 為什麼我的 Quicksight 資料一直導入失敗?
A2: 請確認您 Quicksight 權限設定中的的 S3 Bucket Write permission 已經正確開啟。
