Skip to content

Commit 3638306

Browse files
authored
Add uptime ratio and response time fields to UptimeKumaMonitor model (#118)
1 parent 0acdf44 commit 3638306

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

pythonkuma/models.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ class UptimeKumaMonitor(UptimeKumaBaseModel):
8484
monitor_url: str | None = field(
8585
metadata={"deserialize": lambda v: None if v == "null" else v}
8686
)
87+
monitor_uptime_ratio_1d: float | None = None
88+
monitor_uptime_ratio_30d: float | None = None
89+
monitor_uptime_ratio_365d: float | None = None
90+
91+
monitor_response_time_seconds_1d: float | None = None
92+
monitor_response_time_seconds_30d: float | None = None
93+
monitor_response_time_seconds_365d: float | None = None
8794

8895

8996
@dataclass

pythonkuma/uptimekuma.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,14 @@ async def metrics(self) -> dict[str | int, UptimeKumaMonitor]:
102102
else sample.labels["monitor_name"]
103103
)
104104

105-
monitors.setdefault(key, sample.labels).update(
106-
{sample.name: sample.value}
105+
name = (
106+
f"{sample.name}_{window}"
107+
if (window := sample.labels.get("window"))
108+
else sample.name
107109
)
108110

111+
monitors.setdefault(key, sample.labels).update({name: sample.value})
112+
109113
return {
110114
key: UptimeKumaMonitor.from_dict(value)
111115
for key, value in monitors.items()

0 commit comments

Comments
 (0)