From 39af9b298b0fd377f11f887812fc2523615300e4 Mon Sep 17 00:00:00 2001 From: tym83 <6355522@gmail.com> Date: Fri, 19 Jun 2026 15:14:14 +0500 Subject: [PATCH] ci(oss-health): re-enable monthly telemetry cron and read total_tenants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cozystack/cozystack-telemetry-server#8 makes /api/overview count entities over the period window (matching Grafana), so the monthly fetch cron is safe to run again — restore the schedule that was paused in #508. Also read tenants from the period's total_tenants field, which #8 populates correctly, instead of the apps.Tenant workaround (kept as a fallback). Without this the quarter/year tenant card would show the month's value, since the server reuses the month's app breakdown for the longer periods. Signed-off-by: tym83 <6355522@gmail.com> --- .github/workflows/fetch-telemetry.yml | 10 +++++++--- hack/fetch_telemetry.py | 9 ++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/fetch-telemetry.yml b/.github/workflows/fetch-telemetry.yml index fd25bf1b..fd25ef27 100644 --- a/.github/workflows/fetch-telemetry.yml +++ b/.github/workflows/fetch-telemetry.yml @@ -1,9 +1,13 @@ name: Fetch Telemetry Data on: - # Keep this as a manual telemetry-only backfill path. The monthly OSS Health - # refresh intentionally does not update telemetry while /api/overview differs - # from the Grafana-backed source of truth. + # Monthly telemetry refresh. /api/overview now counts entities over the period + # window instead of at an instant (cozystack/cozystack-telemetry-server#8), so + # it matches the Grafana-backed source of truth and is safe to consume on a + # schedule again. Aligned with the monthly OSS Health cron; workflow_dispatch + # remains for manual backfills. + schedule: + - cron: '0 4 1 * *' workflow_dispatch: permissions: diff --git a/hack/fetch_telemetry.py b/hack/fetch_telemetry.py index 2f9d7d8e..06f0a64c 100755 --- a/hack/fetch_telemetry.py +++ b/hack/fetch_telemetry.py @@ -8,8 +8,9 @@ 3. Merge case-insensitive / Pax* / legacy-name aliases into one canonical entry per application, keeping the maximum instance count (zero-count entries left after the merge are dropped from the table). -4. Pull `Tenant` out of the apps map and surface it as the top-level Tenants - summary card (the raw `total_tenants` field from the API is always zero). +4. Surface tenant count as the top-level Tenants summary card, preferring the + period's `total_tenants` field (correct since telemetry-server #8) and + falling back to `apps.Tenant` for older payloads where it was zero. 5. Emit the payload in the shape consumed by `oss-health-app.html` + `renderTelemetry`, including `summary_cards`, `apps`, `range`. @@ -100,7 +101,9 @@ def transform_period(raw_period: dict, label_fallback: str) -> dict | None: if not raw_period: return None apps_raw = raw_period.get("apps", {}) or {} - tenants = int(apps_raw.get("Tenant", 0)) + # Prefer the period's own total_tenants (correct since telemetry-server #8); + # fall back to apps.Tenant for older payloads where total_tenants was 0. + tenants = int(raw_period.get("total_tenants") or apps_raw.get("Tenant", 0)) clusters = int(raw_period.get("clusters", 0)) total_nodes = int(raw_period.get("total_nodes", 0)) avg_nodes = raw_period.get("avg_nodes_per_cluster")