Browse Source

Replace LF with two spaces

Grafana v8.0.0 and newer (AlertingNG) changed the message format and sends a multi-line string.
master
JustAnotherArchivist 2 years ago
parent
commit
e9a9b74599
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      contrib/modules/grafana.py

+ 2
- 1
contrib/modules/grafana.py View File

@@ -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}'

Loading…
Cancel
Save