Update to first fully working version.
This commit is contained in:
parent
4788f36e55
commit
2079268b5d
45
README.md
Normal file
45
README.md
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
This application will send Alertmanager alerts through to Gotify.
|
||||||
|
|
||||||
|
# Notes
|
||||||
|
* Forwards `resolved` alerts, if sent.
|
||||||
|
* Defaults, if not sent:
|
||||||
|
| Field | Default value |
|
||||||
|
|-------------|---------------|
|
||||||
|
| Priority | `5` |
|
||||||
|
| Description | `...` |
|
||||||
|
| Severity | `Default` |
|
||||||
|
|
||||||
|
|
||||||
|
# Docker
|
||||||
|
## Run
|
||||||
|
|
||||||
|
e.g.
|
||||||
|
```bash
|
||||||
|
docker run -e TZ=Europe/London -e GOTIFY_KEY=XXXXXXXX -e GOTIFY_SERVER=gotify -e GOTIFY_PORT=80 alertify:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
## Compose:
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
version: "2"
|
||||||
|
services:
|
||||||
|
gotify:
|
||||||
|
image: gotify/server:latest
|
||||||
|
container_name: gotify
|
||||||
|
environment:
|
||||||
|
- TZ=Europe/London
|
||||||
|
volumes:
|
||||||
|
- config/config.yml:/etc/gotify/config.yml
|
||||||
|
- data:/app/data
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
alertify:
|
||||||
|
image: alertify:latest
|
||||||
|
container_name: alertify
|
||||||
|
environment:
|
||||||
|
- TZ=Europe/London
|
||||||
|
- GOTIFY_KEY=XXXXXXXXXXXX
|
||||||
|
- GOTIFY_SERVER=gotify
|
||||||
|
- GOTIFY_PORT=80
|
||||||
|
restart: unless-stopped
|
||||||
|
```
|
11
alertify.py
11
alertify.py
|
@ -71,12 +71,17 @@ class HTTPHandler(SimpleHTTPRequestHandler):
|
||||||
|
|
||||||
alert = json.loads(rawdata.decode())
|
alert = json.loads(rawdata.decode())
|
||||||
|
|
||||||
|
if alert['status'] == 'resolved':
|
||||||
|
prefix = 'Resolved'
|
||||||
|
else:
|
||||||
|
prefix = alert['commonLabels'].get('severity', 'default').capitalize()
|
||||||
|
|
||||||
gotify_msg = {
|
gotify_msg = {
|
||||||
'message': '{}: {}'.format(
|
'message': '{}: {}'.format(
|
||||||
alert['commonLabels']['severity'].capitalize(),
|
prefix,
|
||||||
alert['commonAnnotations']['description']
|
alert['commonAnnotations'].get('description', '...')
|
||||||
),
|
),
|
||||||
'priority': int(alert['commonLabels']['priority']) or 5
|
'priority': int(alert['commonLabels'].get('priority', 5))
|
||||||
}
|
}
|
||||||
|
|
||||||
(status, reason) = gotify_send(
|
(status, reason) = gotify_send(
|
||||||
|
|
|
@ -1,3 +1 @@
|
||||||
# To ensure app dependencies are ported from your virtual environment/host machine into your container, run 'pip freeze > requirements.txt' in the terminal to overwrite this file
|
# To ensure app dependencies are ported from your virtual environment/host machine into your container, run 'pip freeze > requirements.txt' in the terminal to overwrite this file
|
||||||
docker
|
|
||||||
prometheus_client
|
|
||||||
|
|
Loading…
Reference in a new issue