fix web page issues

This commit is contained in:
Andreas Wrede
2026-04-04 12:43:30 -04:00
parent 941f3ea4b0
commit 73aa89f8f4
3 changed files with 91 additions and 27 deletions
+10 -2
View File
@@ -114,11 +114,19 @@ class AlertState:
def to_dict(self) -> dict:
"""Convert alert state to dictionary for serialization."""
import math
# Helper to sanitize numeric values for JSON (handle inf/nan)
def sanitize_value(val):
if isinstance(val, float) and (math.isinf(val) or math.isnan(val)):
return None
return val
result = {
"metric_path": self.metric_path,
"level": self.level.name,
"since": self.since,
"last_value": self.last_value,
"last_value": sanitize_value(self.last_value),
"last_check": self.last_check,
"notification_count": self.notification_count,
"acknowledged": self.acknowledged,
@@ -130,7 +138,7 @@ class AlertState:
# Include threshold info if available
if self.threshold_value is not None:
result["threshold_value"] = self.threshold_value
result["threshold_value"] = sanitize_value(self.threshold_value)
if self.operator is not None:
result["operator"] = self.operator
if self.formatted_message is not None: