generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 5
Transition to pyiceberg #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
itakserman-cloudinary
wants to merge
20
commits into
aws-samples:main
Choose a base branch
from
itakserman-cloudinary:transition_to_pyiceberg
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
02b0e46
Initial commit
itakserman-cloudinary dbc81f9
finalize tests
itakserman-cloudinary 53c13c8
finalize tests
itakserman-cloudinary 649cd88
Adjust readme
itakserman-cloudinary 0c8b47c
slight updates
itakserman-cloudinary 4f6fab4
Update template
itakserman-cloudinary eb7230e
Update template
itakserman-cloudinary 41fe55e
Adjust readme
itakserman-cloudinary e157ddb
finalize tests
itakserman-cloudinary bd480e1
linting
itakserman-cloudinary e2d7d9d
Support partition of complex types and multiple columns
itakserman-cloudinary e118a22
Repalce readme arch diagram
itakserman-cloudinary 882c58c
gitignore
itakserman-cloudinary a14126c
Add deploy from ECR
itakserman-cloudinary f9fce1a
Add deploy from ECR
itakserman-cloudinary e3f9772
Add deploy from ECR
itakserman-cloudinary a0c2075
Add deploy from ECR
itakserman-cloudinary 8bd7f93
Add deploy from ECR
itakserman-cloudinary d02e9bf
pr comments
itakserman-cloudinary fedb2f3
pr comments
itakserman-cloudinary File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,6 @@ This repository provides you with a sample solution that collects metrics of exi | |
| ### Solution Tenets | ||
| * Solution is designed to provide time-series metrics for Apache Iceberg to monitor Apache Iceberg tables over-time to recognize trends and anomalies. | ||
| * Solution is designed to be lightweight and collect metrics exclusively from Apache Iceberg metadata layer without scanning the data layer hense without the need for heavy compute capacity. | ||
| * In the future we strive to reduce the dependency on AWS Glue in favor of using AWS Lambda compute when required features are available in [PyIceberg](https://py.iceberg.apache.org) library. | ||
|
|
||
| ### Technical implementation | ||
|
|
||
|
|
@@ -90,7 +89,7 @@ https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/i | |
|
|
||
| ### Build and Deploy | ||
|
|
||
| > ! Important - The guidance below uses AWS Serverless Application Model (SAM) for easier packaging and deployment of AWS Lambda. However if you use your own packaging tool or if you want to deploy AWS Lambda manually you can explore following files: | ||
| > ! Important - The guidance below uses AWS Serverless Application Model (SAM) and Amazon ECR for easier packaging and deployment of AWS Lambda. However if you use your own packaging tool or if you want to deploy AWS Lambda manually you can explore following files: | ||
| > - template.yaml | ||
| > - lambda/requirements.txt | ||
| > - lambda/app.py | ||
|
|
@@ -100,22 +99,30 @@ https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/i | |
| Once you've installed [Docker](#install-docker) and [SAM CLI](#install-sam-cli) you are ready to build the AWS Lambda. Open your terminal and run command below. | ||
|
|
||
| ```bash | ||
| cd lambda | ||
| docker build -f Dockerfile --platform linux/amd64 -t iceberg-monitoring:main --build-arg CLOUDWATCH_NAMESPACE={{ cw_namespace }} . | ||
| sam build --use-container | ||
| ``` | ||
|
|
||
| #### 2. Deploy AWS Lambda using AWS SAM CLI | ||
| #### 2. Deploy AWS Lambda using AWS SAM CLI and Amazon ECR | ||
|
|
||
| Once build is finished you can deploy your AWS Lambda. SAM will upload packaged code and deploy AWS Lambda resource using AWS CloudFormation. Run below command using your terminal. | ||
| Once build is finished you can deploy your AWS Lambda. ECR will upload packaged code and SAM will deploy AWS Lambda resource using AWS CloudFormation. Run below command using your terminal. | ||
|
|
||
| ```bash | ||
| sam deploy --guided | ||
| aws ecr get-login-password --region {{ aws_region }} | docker login --username AWS --password-stdin {{ aws_account_id }}.dkr.ecr.us-east-1.amazonaws.com | ||
| aws ecr create-repository --repository-name iceberg-monitoring --region {{ aws_region }} --image-scanning-configuration scanOnPush=true --image-tag-mutability MUTABLE | ||
| docker tag iceberg-monitoring:main {{ ecr_repository_uri }}:latest | ||
| docker push {{ aws_account_id }}.dkr.ecr.{{ aws_region }}.amazonaws.com/iceberg-monitoring:latest | ||
| sam deploy --debug --region {{ aws_region }} \ | ||
|
||
| --parameter-overrides ImageURL={{ aws_account_id }}.dkr.ecr.{{ aws_region }}.amazonaws.com/iceberg-monitoring:latest \ | ||
| --image-repository {{ aws_account_id }}.dkr.ecr.{{ aws_region }}.amazonaws.com/iceberg-monitoring \ | ||
| --stack-name iceberg-monitoring --capabilities CAPABILITY_IAM CAPABILITY_AUTO_EXPAND \ | ||
| --s3-bucket {{ s3_bucket }} --s3-prefix iceberg-monitoring | ||
| ``` | ||
|
|
||
| ##### Parameters | ||
|
|
||
| - `CWNamespace` - A namespace is a container for CloudWatch metrics. | ||
| - `GlueServiceRole` - AWS Glue Role arn you created [earlier](#configuring-iam-permissions-for-aws-glue). | ||
| - `Warehouse` - Required catalog property to determine the root path of the data warehouse on S3. This can be any path on your S3 bucket. Not critical for the solution. | ||
| - `CLOUDWATCH_NAMESPACE` - A namespace is a container for CloudWatch metrics. | ||
|
|
||
|
|
||
| #### 3. Configure EventBridge Trigger | ||
|
|
@@ -235,6 +242,16 @@ sam local invoke IcebergMetricsLambda --env-vars .env.local.json | |
| `.env.local.json` - The JSON file that contains values for the Lambda function's environment variables. Lambda code is dependent on env vars that you are passing in the deploy section. You need to create the file it and include relevant [parameters](#parameters) before you calling `sam local invoke`. | ||
|
|
||
|
|
||
| ### Unit Tests | ||
|
|
||
| You can test the metrics generation locally through unit-tests. From lambda folder - | ||
|
|
||
| ```bash | ||
| cd lambda | ||
| docker build -f tests/Dockerfile -t iceberg-metrics-tests . | ||
moryachok marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| docker run --rm iceberg-metrics-tests | ||
| ``` | ||
|
|
||
| ## Dependencies | ||
|
|
||
| PyIceberg is a Python implementation for accessing Iceberg tables, without the need of a JVM. \ | ||
|
|
||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| FROM public.ecr.aws/lambda/python:3.10 | ||
|
|
||
| COPY . ${LAMBDA_TASK_ROOT} | ||
|
|
||
| # Install the function's dependencies | ||
| RUN pip install --upgrade pip && \ | ||
| pip install -r requirements.txt | ||
|
|
||
| ARG CLOUDWATCH_NAMESPACE | ||
| ENV CW_NAMESPACE=$CLOUDWATCH_NAMESPACE | ||
|
|
||
| CMD [ "app.lambda_handler" ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using ECR for lambda packaging block looks good, but I would make it more easier for developers by suggesting bash env vars before the commands, like so:
Once defined those let them just run the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@moryachok - done I think :)