diff --git a/backend/fluksio/cloud/connector.py b/backend/fluksio/cloud/connector.py index ab1ee0d..2152e19 100644 --- a/backend/fluksio/cloud/connector.py +++ b/backend/fluksio/cloud/connector.py @@ -255,19 +255,32 @@ class CloudConnector: Fetched through the same in-process transport as everything else, with a short-lived local token: the observability API is authenticated, and this process is entitled to mint one for the enrolling user. + + ``failures_24h`` is added here rather than by ``/summary``: it is the + portal's tile and nothing on this installation reads it, and summing + the same rollups over the same window the app's own Home tile sums + keeps the two from drifting apart the way they already did once. """ from fluksio.core import security token = security.create_access_token(config.local_user_id, timedelta(minutes=5)) + headers = {"Authorization": f"Bearer {token}"} try: async with self._client() as client: response = await client.get( - "/api/v1/observability/summary", - headers={"Authorization": f"Bearer {token}"}, + "/api/v1/observability/summary", headers=headers ) - if response.status_code == 200: + if response.status_code != 200: + return None summary: dict[str, Any] = response.json() - return summary + rollups = await client.get( + "/api/v1/observability/flows", + params={"hours": 24}, + headers=headers, + ) + if rollups.status_code == 200: + summary["failures_24h"] = sum(row["errors"] for row in rollups.json()) + return summary except Exception: logger.debug("Could not collect a health summary for the portal") return None