From 7e5a90886f7d544bc3995604f03bf0aaa2415173 Mon Sep 17 00:00:00 2001 From: tr4nt0r <4445816+tr4nt0r@users.noreply.github.com> Date: Wed, 11 Feb 2026 01:32:05 +0100 Subject: [PATCH] Add uptime ratio and response time fields to UptimeKumaMonitor model --- pythonkuma/models.py | 7 +++++++ pythonkuma/uptimekuma.py | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pythonkuma/models.py b/pythonkuma/models.py index 52753dc..d6ae91c 100644 --- a/pythonkuma/models.py +++ b/pythonkuma/models.py @@ -84,6 +84,13 @@ class UptimeKumaMonitor(UptimeKumaBaseModel): monitor_url: str | None = field( metadata={"deserialize": lambda v: None if v == "null" else v} ) + monitor_uptime_ratio_1d: float | None = None + monitor_uptime_ratio_30d: float | None = None + monitor_uptime_ratio_365d: float | None = None + + monitor_response_time_seconds_1d: float | None = None + monitor_response_time_seconds_30d: float | None = None + monitor_response_time_seconds_365d: float | None = None @dataclass diff --git a/pythonkuma/uptimekuma.py b/pythonkuma/uptimekuma.py index 4048a69..d83ee70 100644 --- a/pythonkuma/uptimekuma.py +++ b/pythonkuma/uptimekuma.py @@ -102,10 +102,14 @@ async def metrics(self) -> dict[str | int, UptimeKumaMonitor]: else sample.labels["monitor_name"] ) - monitors.setdefault(key, sample.labels).update( - {sample.name: sample.value} + name = ( + f"{sample.name}_{window}" + if (window := sample.labels.get("window")) + else sample.name ) + monitors.setdefault(key, sample.labels).update({name: sample.value}) + return { key: UptimeKumaMonitor.from_dict(value) for key, value in monitors.items()