mirror of
https://github.com/bsedin/matrix-webhook.git
synced 2026-04-09 11:25:40 +00:00
Support Grafana v9.x messages, fixes #29
This commit is contained in:
@@ -4,8 +4,10 @@ import re
|
||||
|
||||
|
||||
def grafana(data, headers):
|
||||
"""Pretty-print a grafana notification."""
|
||||
"""Pretty-print a Grafana (version 8 and older) notification."""
|
||||
text = ""
|
||||
if "ruleName" not in data and "alerts" in data:
|
||||
return grafana_9x(data, headers)
|
||||
if "title" in data:
|
||||
text = "#### " + data["title"] + "\n"
|
||||
if "message" in data:
|
||||
@@ -17,6 +19,17 @@ def grafana(data, headers):
|
||||
return data
|
||||
|
||||
|
||||
def grafana_9x(data, headers):
|
||||
"""Pretty-print a Grafana newer than v9.x notification."""
|
||||
text = ""
|
||||
if "title" in data:
|
||||
text = "#### " + data["title"] + "\n"
|
||||
if "message" in data:
|
||||
text = text + data["message"].replace("\n", "\n\n") + "\n\n"
|
||||
data["body"] = text
|
||||
return data
|
||||
|
||||
|
||||
def github(data, headers):
|
||||
"""Pretty-print a github notification."""
|
||||
# TODO: Write nice useful formatters. This is only an example.
|
||||
|
||||
Reference in New Issue
Block a user