From 0cb79d734aa7f226e981b44e14d7224a41a94251 Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Sun, 25 Oct 2020 08:41:19 +0000 Subject: [PATCH] Removed defaults for instance and description --- README.md | 2 -- src/alertify/messaging.py | 8 +++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7273187..13ba164 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,6 @@ The following environment variables will override any config or default: * Defaults, if not sent: | Field | Default value | |-------------|---------------| - | Description | `[nodata]` | - | Instance | `[unknown]` | | Priority | `5` | | Severity | `Warning` | diff --git a/src/alertify/messaging.py b/src/alertify/messaging.py index 8a4981c..eb4778e 100644 --- a/src/alertify/messaging.py +++ b/src/alertify/messaging.py @@ -37,14 +37,16 @@ class MessageHandler: else: prefix = alert['labels'].get('severity', 'warning') + instance = alert['labels'].get('instance', None) + gotify_msg = { 'title': '[{}] {}'.format( prefix.upper(), alert['annotations'].get('summary'), ), - 'message': '{}: {}'.format( - alert['labels'].get('instance', '[unknown]'), - alert['annotations'].get('description', '[nodata]'), + 'message': '{}{}'.format( + f'{instance}: ' if instance else '', + alert['annotations'].get('description', ''), ), 'priority': int(alert['labels'].get('priority', 5)), 'extras': {