Code Monkey home page Code Monkey logo

game-analytics-pipeline's Introduction

Disclaimer

This Game Analytics Pipeline (v1) solution has been upgraded to a v2. The new repository is located here with steps on deployment: https://github.com/aws-solutions-library-samples/guidance-for-game-analytics-pipeline-on-aws/tree/main

AWS Game Analytics Pipeline Solution

Many Amazon Web Services (AWS) games customers want to build their own custom analytics solutions that provide flexibility and customization without the complexity of managing infrastructure.

The Game Analytics Pipeline Solution is a reference implementation of a serverless analytics pipeline that provides a solution for ingesting telemetry events from games and backend services. The solution addresses both real-time and batch analytics and integrates with AWS Glue and Amazon Simple Storage Service (Amazon S3) to provide data lake integration and cost effective storage.

Getting Started

  1. Start by reviewing the Implementation Guide. This guide provides an overview of the solution and how it works. A PDF version is also available.

  2. Next, check out the Developer Guide which provides information about customizing and extending the Game Analytics Pipeline solution. It includes detailed information about how the solution components work and how they can be customized.

The solution source artifacts are provided in this repository to enable customization to the game analytics pipeline solution before deployment. To customize the solution source code and templates, an S3 Bucket is required to host assets used during the build and deployment process.

The build script provided with the solution can be run manually from a command line or can be executed within an automated build/release pipeline. The build script has been tested on Amazon Linux 2 platform. AWS CodeBuild can be used to automate the build process and provides a variety of custom build environments that you can choose from, including Amazon Linux 2.

1. Prerequisites

The following procedures assumes that all of the OS-level configuration has been completed. They are:

The game analytics pipeline solution is developed with Node.js for the backend services that run in AWS Lambda. The latest version of the game analytics pipeline solution has been tested with Node.js v12.x. The solution also includes a demo script for generating sample game events, which is developed in Python and tested with Python 3.x.

Note: Python is not required to be installed on the system unless the sample events generator Python script is used. Additional prerequisites may be required if customization includes changing the solution code to use another runtime within AWS Lambda.

2. Clone the game analytics pipeline solution

git clone https://github.com/awslabs/game-analytics-pipeline.git

The build process requires the use of an Amazon S3 Bucket to store packaged artifacts. The build script packages the AWS Lambda Functions into zip files and stores them in the S3 Bucket for reference by the CloudFormation template during deployment. The S3 Bucket must exist in the same AWS Region where the CloudFormation template will be deployed.

3. Configure environment:

The solution build script requires environment variables to be configured prior to building the solution. Configure the below environment variables:

export AWS_REGION=<AWS Region code>
export VERSION=<Provide a version for your deployment. Build output artficats are stored in S3 prefix using this version name>
export SOLUTION_NAME=<Provide a solution name for your deployment>   
export DIST_OUTPUT_BUCKET=<A name used for the S3 Bucket that will host build output artifacts>

4. Create an S3 Bucket for storing build artifacts in a supported AWS Region:

Create an S3 bucket with the region code appended to the name of the bucket, so that AWS CloudFormation can reference regionally hosted assets.

aws s3 mb s3://$DIST_OUTPUT_BUCKET-$AWS_REGION --region $AWS_REGION

Note: In order to simplify the solution deployment, the build script automatically builds and re-packages each AWS Lambda Function during each build script execution. The script can be modified to support custom build and deployment requirements and the environment variables can be configured automatically in build tools, including AWS CodeBuild.

5. Build the game analytics pipeline solution for deployment:

Execute the following commands to build the solution:

cd ./deployment
chmod +x ./build-s3-dist.sh
./build-s3-dist.sh $DIST_OUTPUT_BUCKET $SOLUTION_NAME $VERSION

6. Upload deployment assets to your Amazon S3 bucket:

aws s3 cp ./global-s3-assets s3://$DIST_OUTPUT_BUCKET-$AWS_REGION/$SOLUTION_NAME/$VERSION --recursive --acl bucket-owner-full-control
aws s3 cp ./regional-s3-assets s3://$DIST_OUTPUT_BUCKET-$AWS_REGION/$SOLUTION_NAME/$VERSION --recursive --acl bucket-owner-full-control

7. Deploy the game analytics pipeline solution:

Deploy the solution CloudFormation template using the local packaged template or by referencing the uploaded template stored in Amazon S3:

aws cloudformation deploy --template-file ./global-s3-assets/game-analytics-pipeline.template --stack-name <STACK_NAME> --capabilities CAPABILITY_IAM  --s3-bucket $DIST_OUTPUT_BUCKET-$AWS_REGION

Include optional parameters as needed, for example to receive SNS notifications from solution alarms, use --parameter-overrides SolutionAdminEmailAddress=<EMAIL_ADDRESS>. A confirmation email is sent to the email address to verify subscription to the SNS Topic.

8. Get started with the Implementation and Developer Guides

Refer to the Implementation Guide for deployment instructions and the Developer Guide for details about customizing and extending the solution.

File Structure

|-deployment/ 
  |-build-s3-dist.sh  [ shell script for packaging distribution assets ] 
  |-game-analytics-pipeline.template  [ CloudFormation deployment template ] 
|-source/ 
  |-services/
    |-events_processing/ [ source code for lambda function that processes ingested events ]
  	|-analytics_processing/ [ Lambda function for processing output from Kinesis Data Analytics application]
  	|-api
  	  |-admin  [ API Microservice used to register new applications and authorizations for sending analytics events]
  	  |-lambda_authorizer  [ API Gateway Lambda Authorizer function used to authorize requests to /events endpoint]
  	|-data_lake  
   	  |-etl_processing/  [  contains PySpark source code for solution ETL Job ]
   	  |-glue_partition_creator/ [ source code for function that creates glue table partitions ]
|-demo/ [ contains the demo Python script for testing the solution with sample datasets]
|-resources/
  |-helper/ [ contains the Lambda custom resource helper function code] 
  |-usage-metrics/	[ source code for generating anonymous usage data]
  |-game-analytics-pipeline_postman_collection.json. [Postman collection file that is provided to help configure Postman for use with the solution]
  	 

Each Lambda Function follows the structure of:

|-service-name/
  |-lib/
    |-[service module libraries and other function artifacts]
  |-index.js [injection point for Lambda handler]
  |-package.json

This solution collects anonymous operational metrics to help AWS improve the quality of features of the solution. For more information, including how to disable this capability, please see the implementation guide.

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: MIT-0

game-analytics-pipeline's People

Contributors

amazon-auto avatar daniel-gmk avatar grecheg avatar hqdrt avatar jeongleeaws avatar kylesomers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

game-analytics-pipeline's Issues

schema_mismatch validation error, when sending events using the solution API events endpoint

When sending events using the
solution API events endpoint, the additionalProperties
property in the JSON schema definition cause validation error
"validation_errors": [ { "keyword": "additionalProperties", "dataPath": "", "schemaPath": "#/additionalProperties", "params": { "additionalProperty": "aws_ga_api_validated_flag" }, "message": "should NOT have additional properties" } ]

because input event has additional fields
"aws_ga_api_validated_flag": true, "aws_ga_api_requestId": "..", "aws_ga_api_requestTimeEpoch": ..,

build-s3-dist.sh does not support MacOS

do_cmd sed -i $replace $file does not do anything on MacOS due to the -i option has different behavior

Pre-requisite is to install gnu-sed on MacOS which will have gsed available, then update the script.

# Check OS before using sed in do_replace
OS=`uname`
do_replace() {
	replace="s/$2/$3/g"
	file=$1
  if [ "$OS" = 'Darwin' ]; then
	  do_cmd gsed -i $replace $file
  else
    do_cmd sed -i $replace $file
  fi
}

Another way is to modify the do_replace() sed -i $replace $file to support cross-platform. https://riptutorial.com/sed/topic/9436/bsd-macos-sed-vs--gnu-sed-vs--the-posix-sed-specification#:~:text=BSD%20sed%20%3A%20always%20appends%20a,input%20line%20ended%20in%20one.

AWS JS SDK V3 not supported by event processor lambda

Using the Kinesis putRecord Method in v3 breaks the Event Processing Lambda, not sure how to fix this. The input data to the lambda seems to be wrong all the time.

My client Code:
kinesis.putRecord({ Data: JSON.stringify({ "event": event, "application_id": "..." }), PartitionKey: uuidv4(), StreamName: '...' }, function (err, data) { if (err) { console.error(err); } else { console.log(data); } });
The data sent seems to be wrong, if i log the received data in the lambda it's some not convertable string

S3 Bucket acl error:InvalidBucketAclWithObjectOwnership

When I launch stack with template, I got error at making s3 bucket below. How can I fix this?

Bucket cannot have ACLs set with ObjectOwnership's BucketOwnerEnforced setting (Service: Amazon S3; Status Code: 400; Error Code: InvalidBucketAclWithObjectOwnership; Request ID: WT76Z4WGSGTHJF0J; S3 Extended Request ID: D+UX2qNjahev9gpFVlZ5QGCT8AA065C5fVy6Aprc1bGToM4WsTaPEPyXHt1c4IrY5bqIsqkCOL1qHCtCwFn/Yg==; Proxy: null)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.