浏览代码

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 年前
父节点
当前提交
e9a9b74599
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. +2
    -1
      contrib/modules/grafana.py

+ 2
- 1
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}'

正在加载...
取消
保存