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 -H, --healthcheck simply exit with 0 for healthy or 1 when unhealthy
The following environment variables will override any config or default: The following environment variables will override any config or default:
* LISTEN_PORT (default: 8080) * DISABLE_RESOLVED (default: False)
* GOTIFY_SERVER (default: localhost) * GOTIFY_KEY (default: None)
* GOTIFY_PORT (default: 80) * GOTIFY_PORT (default: 80)
* GOTIFY_KEY (default: None) * GOTIFY_SERVER (default: localhost)
* VERBOSE (default: False) * LISTEN_PORT (default: 8080)
* VERBOSE (default: False)
``` ```

View file

@ -15,10 +15,11 @@ from http.server import HTTPServer, SimpleHTTPRequestHandler
import yaml import yaml
DEFAULTS = { DEFAULTS = {
'listen_port': int(8080), 'disable_resolved': bool(False),
'gotify_server': str('localhost'),
'gotify_port': int(80),
'gotify_key': str(), 'gotify_key': str(),
'gotify_port': int(80),
'gotify_server': str('localhost'),
'listen_port': int(8080),
'verbose': bool(False), 'verbose': bool(False),
} }
@ -92,6 +93,10 @@ class HTTPHandler(SimpleHTTPRequestHandler):
try: try:
if alert['status'] == 'resolved': 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' prefix = 'Resolved'
else: else:
prefix = alert['commonLabels'].get( prefix = alert['commonLabels'].get(

View file

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