Alerts: prevent crash on unknown severity level
This commit is contained in:
parent
313795d050
commit
a9748f409d
1 changed files with 3 additions and 3 deletions
|
@ -37,7 +37,7 @@ class Alert:
|
|||
self.description = annotations["description"]
|
||||
|
||||
if self.firing:
|
||||
self.status = self.labels["severity"]
|
||||
self.status = self.labels.get("severity", "unknown_alert")
|
||||
else:
|
||||
self.status = "resolved"
|
||||
|
||||
|
@ -55,11 +55,11 @@ class Alert:
|
|||
|
||||
@property
|
||||
def emoji(self) -> str:
|
||||
return self.EMOJIS[self.status]
|
||||
return self.EMOJIS.get(self.status, "❓️")
|
||||
|
||||
@property
|
||||
def color(self) -> str:
|
||||
return self.COLORS[self.status]
|
||||
return self.COLORS.get(self.status, "ffff0c")
|
||||
|
||||
def match_label(self, label_name: str, pattern: re.Pattern[str]) -> bool:
|
||||
if label_name not in self.labels:
|
||||
|
|
Loading…
Reference in a new issue