From bca1d919b2d8b39342f10df34a113db10c20058c Mon Sep 17 00:00:00 2001 From: Alex Kelly Date: Tue, 21 Jan 2025 10:26:07 -0500 Subject: [PATCH] add alertmanager formatter --- matrix_webhook/formatters/alertmanager.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 matrix_webhook/formatters/alertmanager.py diff --git a/matrix_webhook/formatters/alertmanager.py b/matrix_webhook/formatters/alertmanager.py new file mode 100644 index 0000000..45f834c --- /dev/null +++ b/matrix_webhook/formatters/alertmanager.py @@ -0,0 +1,8 @@ + +def formatter(data, headers): + """Pretty-print an alertmanager notification.""" + text = "" + for alert in data['alerts']: + text += f"[{alert['status']}] - {alert['labels']['summary']}\n\n" + data["body"] = text + return data