mirror of
https://github.com/bsedin/matrix-webhook.git
synced 2026-04-09 11:25:40 +00:00
add grafana formatter
This was initially designed and implemented in #4 Co-authored-by: Sven Seeberg <mail@sven-seeberg.de>
This commit is contained in:
15
matrix_webhook/formatters.py
Normal file
15
matrix_webhook/formatters.py
Normal file
@@ -0,0 +1,15 @@
|
||||
"""Formatters for matrix webhook."""
|
||||
|
||||
|
||||
def grafana(data):
|
||||
"""Pretty-print a grafana notification."""
|
||||
text = ""
|
||||
if "title" in data:
|
||||
text = "### " + data["title"] + "\n"
|
||||
if "message" in data:
|
||||
text = text + data["message"] + "\n\n"
|
||||
if "evalMatches" in data:
|
||||
for match in data["evalMatches"]:
|
||||
text = text + "* " + match["metric"] + ": " + str(match["value"]) + "\n"
|
||||
data["body"] = text
|
||||
return data
|
||||
Reference in New Issue
Block a user