fix web page issues
This commit is contained in:
+10
-2
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user