2021-11-03 17:02:22 -04:00
|
|
|
def formatter(data, headers):
|
2021-11-03 16:12:52 -04:00
|
|
|
"""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
|