handle optional alert job

This commit is contained in:
HgO 2022-07-28 11:11:50 +02:00
parent 810f9e2ceb
commit 6896908432

View file

@ -55,9 +55,13 @@ class Alert:
def html(self) -> str:
alertname = self.labels["alertname"]
job = self.labels["job"]
job = self.labels.get("job", "")
if job:
job = f"({job})"
description = self.annotations["description"]
return (
f"<font color='#{self.color}'><b>[{self.emoji} {self.status.upper()}]</b></font> "
f"<a href='{self.url}'>{alertname}</a> ({job})<br/>{description}"
f"<a href='{self.url}'>{alertname}</a> {job}<br/>{description}"
)