-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
259 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,17 @@ | ||
# This file specifies files that are *not* uploaded to Google Cloud Platform | ||
# using gcloud. It follows the same syntax as .gitignore, with the addition of | ||
# "#!include" directives (which insert the entries of the given .gitignore-style | ||
# file at that point). | ||
# | ||
# For more information, run: | ||
# $ gcloud topic gcloudignore | ||
# | ||
.gcloudignore | ||
# If you would like to upload your .git directory, .gitignore file or files | ||
# from your .gitignore file, remove the corresponding line | ||
# below: | ||
.git | ||
.gitignore | ||
|
||
node_modules | ||
#!include:.gitignore |
This file contains 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 |
---|---|---|
@@ -1 +1,15 @@ | ||
# sentry-alert-to-slack-with-functions | ||
# sentry-alert-to-slack-with-functions | ||
|
||
## Deploy | ||
|
||
```shell | ||
poetry export -f requirements.txt > requirements.txt | ||
gcloud functions deploy sentry-alert-to-slack-with-functions --runtime python37 --trigger-http --entry-point entry_point --region {region} --set-env-vars SLACK_ENDPOINT={SLACK_WEBHOOK_ENDPOINT} | ||
``` | ||
|
||
## Example alert | ||
|
||
``` | ||
An error occurred, for details from the issue below url. | ||
https://sentry.io/organizations/{project_name}/issues/{id}/?referrer=webhooks_plugin | ||
``` |
This file contains 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,29 @@ | ||
import json | ||
import os | ||
from typing import Any, Dict | ||
|
||
from agraffe import Agraffe | ||
|
||
from fastapi import FastAPI, Request | ||
|
||
import requests | ||
|
||
app = FastAPI() | ||
|
||
|
||
@app.post("/sentry") | ||
async def printf(request: Request) -> Dict[str, str]: | ||
body = await request.json() | ||
payload = {"text": (f"An error occurred, for details from the issue below url." | ||
f"\r\n{body['url']}")} | ||
res = requests.post(os.environ["SLACK_ENDPOINT"], | ||
data=json.dumps(payload), | ||
headers={"Content-Type": "application/json"}) | ||
if res.status_code != 200: | ||
raise Exception(f"Error request to slack. [{res.status_code}]") | ||
return {} | ||
|
||
|
||
def entry_point(request: Any) -> Agraffe: | ||
agraffe = Agraffe(app) | ||
return agraffe(request) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,17 @@ | ||
[tool.poetry] | ||
name = "sentry-alert-to-slack-with-functions" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["fealone <fealone@lonesec.com>"] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.7" | ||
fastapi = "^0.61.1" | ||
agraffe = "^0.1.0" | ||
requests = "^2.24.0" | ||
|
||
[tool.poetry.dev-dependencies] | ||
|
||
[build-system] | ||
requires = ["poetry>=0.12"] | ||
build-backend = "poetry.masonry.api" |