From e9a9b745990cfcef4c096ae13e9ca46ec6855aa5 Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Tue, 7 Dec 2021 06:34:34 +0000 Subject: [PATCH] Replace LF with two spaces Grafana v8.0.0 and newer (AlertingNG) changed the message format and sends a multi-line string. --- contrib/modules/grafana.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/modules/grafana.py b/contrib/modules/grafana.py index 75025ce..2fde817 100644 --- a/contrib/modules/grafana.py +++ b/contrib/modules/grafana.py @@ -5,6 +5,7 @@ async def process(request): obj = json.loads(await request.text()) evalMatchesStr = (': ' + ', '.join(f'{x["metric"]} = {x["value"]}' for x in obj['evalMatches'])) if 'evalMatches' in obj and obj['evalMatches'] else '' if 'message' in obj: - return f'{obj["title"]} - {obj["message"]}{evalMatchesStr}' + message = obj['message'].replace('\n', ' ') + return f'{obj["title"]} - {message}{evalMatchesStr}' else: return f'{obj["title"]}{evalMatchesStr}'