Add the ability to disabled resolved messages

Resolves #5
This commit is contained in:
Scott Wallace 2020-10-20 17:52:12 +01:00
parent 3dff3c9121
commit 3c57c113cd
3 changed files with 17 additions and 10 deletions

View file

@ -13,11 +13,12 @@ optional arguments:
-H, --healthcheck simply exit with 0 for healthy or 1 when unhealthy
The following environment variables will override any config or default:
* LISTEN_PORT (default: 8080)
* GOTIFY_SERVER (default: localhost)
* GOTIFY_PORT (default: 80)
* GOTIFY_KEY (default: None)
* VERBOSE (default: False)
* DISABLE_RESOLVED (default: False)
* GOTIFY_KEY (default: None)
* GOTIFY_PORT (default: 80)
* GOTIFY_SERVER (default: localhost)
* LISTEN_PORT (default: 8080)
* VERBOSE (default: False)
```

View file

@ -15,10 +15,11 @@ from http.server import HTTPServer, SimpleHTTPRequestHandler
import yaml
DEFAULTS = {
'listen_port': int(8080),
'gotify_server': str('localhost'),
'gotify_port': int(80),
'disable_resolved': bool(False),
'gotify_key': str(),
'gotify_port': int(80),
'gotify_server': str('localhost'),
'listen_port': int(8080),
'verbose': bool(False),
}
@ -92,6 +93,10 @@ class HTTPHandler(SimpleHTTPRequestHandler):
try:
if alert['status'] == 'resolved':
if self.config.get('disable_resolved'):
print('Ignoring resolved messages')
self._respond(200, 'Ignored. "resolved" messages are disabled')
return
prefix = 'Resolved'
else:
prefix = alert['commonLabels'].get(

View file

@ -1,6 +1,7 @@
---
# verbose: true
gotify_server: gotifyserver.example.net
disable_resolved: false
gotify_key: sOmEsEcReTkEy1
gotify_port: "80"
gotify_server: gotifyserver.example.net
listen_port: "8080"
verbose: true