handle optional alert job
This commit is contained in:
parent
810f9e2ceb
commit
6896908432
1 changed files with 6 additions and 2 deletions
|
@ -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}"
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue