matrix-webhook/matrix_webhook/formatters.py

16 lines
467 B
Python
Raw Normal View History

"""Formatters for matrix webhook."""
2021-08-27 14:05:08 -04:00
def grafana(data, headers):
"""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