Skip to content

Commit

Permalink
Merge branch 'main' into snyk-fix-d7feed573a584eb79e49c8bf28d50b89
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachinbisht27 authored May 8, 2024
2 parents 7bab04e + 4859eaa commit c7ac11d
Show file tree
Hide file tree
Showing 17 changed files with 229 additions and 103 deletions.
12 changes: 6 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Add env variables here
TESTING=
DATASET_ID=
DATASET_LOCATION=
DEBUG=
SLACK_TOKEN=
SLACK_CHANNEL=
ENVIRONMENT=
DATASET_ID=
TABLE_ID=
GOOGLE_APPLICATION_CREDENTIALS=
DATASET_LOCATION=
SLACK_CHANNEL=
SLACK_TOKEN=
TABLE_ID=
TESTING=
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/custom.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Custom issue template
about: Describe this issue template's purpose here.
title: ''
labels: ''
assignees: ''

---


20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
52 changes: 39 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
exclude: "^\
(third-party/.*)\
"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- id: check-yaml
- id: check-merge-conflict
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files # prevents giant files from being committed.
- id: check-case-conflict # checks for files that would conflict in case-insensitive filesystems.
- id: check-merge-conflict # checks for files that contain merge conflict strings.
- id: check-yaml # checks yaml files for parseable syntax.
- id: detect-private-key # detects the presence of private keys.
- id: end-of-file-fixer # ensures that a file is either empty, or ends with one newline.
- id: fix-byte-order-marker # removes utf-8 byte order marker.
- id: mixed-line-ending # replaces or checks mixed line ending.
- id: requirements-txt-fixer # sorts entries in requirements.txt.
- id: trailing-whitespace # trims trailing whitespace.

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
files: \.(js|ts|jsx|tsx|css|less|html|json|markdown|md|yaml|yml)$

- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
args: [--profile=black]

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
hooks:
- id: clang-format
51 changes: 27 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,50 @@
# gcp-budget-alerts-service
The micro-service is for tracking and monitoring the spending amount at the GCP service. This micro-service elevates an alert whenever the overall budget surpasses or meets predefined thresholds.

The microservice is for tracking and monitoring the spending amount at the GCP service. This microservice elevates an alert whenever the overall budget surpasses or meets predefined thresholds.

## Architecture

![_ Expected architecture for the Alert service](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/86e87e12-824a-46a9-ba95-07edca694285)
<h6 align="center">Architecture for the Alert Service</h6>

<h6 align="center">Architecture for the Alert Service</h6>

## Installation Guideline

### Prerequisite

1. pyenv
2. python 3.8
3. A Slack App for delivering messages on the channel. [Setup Guideline](./SLACKAPP.md)

### Steps

1. Clone the repository
```sh
git clone https://github.com/Sachinbisht27/gcp-budget-alerts-service.git
```
```sh
git clone https://github.com/Sachinbisht27/gcp-budget-alerts-service.git
```
2. Switch to project folder and setup the vertual environment
```sh
cd gcp-alerts
python -m venv venv
```
```sh
cd gcp-alerts
python -m venv venv
```
3. Activate the virtual environment
```sh
source ./venv/bin/activate
```
```sh
source ./venv/bin/activate
```
4. Install the dependencies:
```sh
pip install -r requirements-dev.txt
```
```sh
pip install -r requirements-dev.txt
```
5. Set up your .env file by copying .env.example
```sh
cp .env.example .env
```
```sh
cp .env.example .env
```
6. Add/update variables in your `.env` file for your environment.
7. Run the following command to get started with pre-commit
```sh
pre-commit install
```
```sh
pre-commit install
```
8. Start the server by following command
```sh
functions_framework --target=handle --debug
```
```sh
functions_framework --target=handle --debug
```
27 changes: 9 additions & 18 deletions SLACKAPP.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,49 @@
# Create a Slack App

# Steps to create an app on Slack
## Steps to create an app on Slack

1. Go to the channel on which you want to install the app
2. Go to the view all members icon on the top right of the channel

![image](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/13cc0d92-076e-4fd5-b985-fb5102efac79)


3. Click on **add app** option
4. Click on **View app directory**
5. Click on the **build** option at the top right of the menu
6. Create an app from scratch
7. Provide a name to the app and assign it to a workspace
8. Go to OAuth and Permission menu

![image (9)](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/252b96f9-ce02-4c74-bcdc-0527b01c3742)


9. Under the scope section, give the app permission to write messages

![image (10)](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/6183d4aa-4577-4fe8-af35-5c8baf28d93c)


10. Install the app to the workspace

![image (11)](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/4b75f0a7-0c34-4abe-b31d-120ed99d8679)


11. Give permission to the app

![image (12)](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/1ef99851-9258-4c87-88f3-22dd7971d665)


12. Once the app is installed copy the OAuth Token as it will be used for authentication.

![image (14)](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/355d7d13-9cef-4d6b-9a6d-894c96685e95)


13. Go to the channel where you want to add app.
14. Click on the `channel name` .
15. Click on the integrations tab here.

![Untitled](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/cc301091-2403-4541-ad55-305224bc7f7c)


16. Then click on the `Add apps`.

![Untitled (2)](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/1cf34c76-a38a-4f85-86c7-dd4ef0241246)


17. Then recognize the newly created app and add to the channel.

![Untitled (3)](https://github.com/Sachinbisht27/gcp-budget-alerts-service/assets/96137915/17cf0b6f-d8bb-4033-81f4-8bc64e543a8e)


You are done installing the app. Enjoy!
1 change: 0 additions & 1 deletion app/helpers/bigquery_helper/bigquery_helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from google.cloud import bigquery


client = bigquery.Client()


Expand Down
6 changes: 6 additions & 0 deletions app/helpers/notification_helper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
Notification Helper Module
This module provides functions for sending notifications.
"""

from app import services


Expand Down
2 changes: 1 addition & 1 deletion app/services/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .slack_service import *
from .budget_service import *
from .slack_service import *
Loading

0 comments on commit c7ac11d

Please sign in to comment.