Support Grafana v9.x messages, fixes #29
This commit is contained in:
parent
3288c3ff5a
commit
e139c3a61b
4 changed files with 157 additions and 1 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue