Skip to content

feat(warehouse): infra_metrics_hourly, hourly host, k8s and container series - #3274

Merged
Makisuo merged 9 commits into
mainfrom
infra-rollup/table
Dec 4, 2026
Merged

Makisuo merged 9 commits into
mainfrom
infra-rollup/table

Conversation

@Makisuo

@Makisuo Makisuo commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Part 1 of 2: the rollup table. Part 2 routes the infra pages through it.

Why

The infra list and detail queries aggregate raw metrics_gauge / metrics_sum points over the whole window. On a real org (32 hosts, about 120 pods), a 7-day window takes:

Query Rows read Time
Hosts list 133M 19.2s
Host detail 73M 17.9s
Pods list 15M 11.9s
Workloads list 24M 9.9s

The hosts list is over the 15s list profile limit.

What

infra_metrics_hourly keeps one row per infra series, hour and retention period, built by two views (sum and gauge).

  • What it covers: the host, k8s and docker metrics the pages read (INFRA_ROLLUP_METRICS).
  • Attributes: ResourceAttributes and Attributes are cut to the keys those pages read. The per-core cpu attribute is dropped, so a host's CPU states fold into one row.
  • Per row: sum, count, max, min, positive-only sum, count and min, first and last seen, and argMin / argMax / peak-time states. That is enough for every aggregate those queries take.
  • Retention: RetentionDays is copied from the raw points, and the table is partitioned (RetentionDays, toDate(Hour)) like the raw tables. An hour from a short-period source expires with its raw points.
  • Migration 0078 (requiredForIngest: false) backfills 90 days in day chunks before creating the views. Local schema v70 rebuilds the table from retained points.
  • Wiring: missing-table detector, warehouse catalog entry, scoped-delete plan.

First deploy

The rollup is not in SKIP_BACKFILL, so Tinybird replays its history on the first deploy, the way aws_metrics_hourly shipped. Matching raw rows per day:

Region Rollup's metrics aws.* (the aws_metrics_hourly replay) All metric rows
US 16.3M 2.2M 312M
EU 2.0M 14.5M 33M

Both replays scan the whole metric tables. This one writes about 7× more on US and less on EU. Rollup rows run about 150 times fewer than raw points: 62k rows a day for the heaviest org.

Verified

  • apps/cli/test/infra-metrics-hourly.test.ts on chDB:
    • the views fold two cores into one row with every stat;
    • each raw point's retention period becomes its own row.
  • clickhouse:schema:check and tinybird:manifest:check are clean.
  • Domain (1824), local-server (165), CLI local-store migrations, and the scoped-delete chDB suites pass.
  • The file is in the CI chDB list.

🤖 Generated with Claude Code


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

IEatCodeDaily and others added 3 commits December 4, 2026 00:13
…k percents

Infra pages showed CPU / memory / disk as bare percents. "Memory 62%" says nothing about whether that is
1 GB or 100 GB, and a pod at 98% of its limit reads the same whether the limit is 64 MB or 4 GB. This puts
the absolute figure beside each percent (tables, stat cards, chart legends and tooltips), from metrics the
collectors already send. A figure is shown only where the data gives one; otherwise the percent stands alone.

Hosts (`listHostsQuery`, `hostDetailSummaryQuery`)
- CPU: busy cores = busy share × `system.cpu.logical.count` ("7.52 / 8 cores").
- Memory: `system.memory.usage{state=used}`; the hostmetrics receiver sends no total and its states do
  not sum to one (`cached` includes `slab_reclaimable`), so total = used bytes ÷ the used share within each
  scrape, averaged over scrapes that carried both ("9.9 GB / 16.0 GB"). Checked against `/proc/meminfo`
  MemTotal byte for byte. All three metrics are read from `metrics_sum` and `metrics_gauge` (the exporter
  routes by data-point type; senders differ), grouped per host and scrape across both.
- Disk: the fullest mount's used and used + free bytes from `system.filesystem.usage`, from the very reading
  its percent comes from (`argMaxIf` on the same mount and freshness rule `diskPct` uses), so used / total
  == diskPct ("41.0 GB / 100 GB"); on a timestamp tie the reading with bytes gives the percent. A used/free
  pair from two scrapes, one state alone, or a newer utilization-only reading gives the percent alone. A
  usage scrape with one state is no fraction at all (it would read 100%), so the mount list and chart skip
  it too. Host detail reads the figures for its one host, not the org.
- Detail charts: CPU states read as cores of the host, memory states as bytes of its total, and each mount
  as bytes of its size (`hostFilesystemTotalsQuery`: used + free per mount, only while it held still) —
  "45% · 7.2 GB" in the legend and tooltip. The totals definition has its own cache revision, since it
  shares the series' id and payload.

Pods (`listPodsQuery`, `podDetailSummaryQuery`): the kubelet sends limit and request shares, not limits, so
each limit or request is usage ÷ share within one sample (one pod by UID, one scrape), and is given only
when every sample agrees and no sample has usage without its share. Then usage over it is exactly the
share beside it, peak or average; a limit resized within the window, samples that disagree, or a pod
without the share show usage alone. The list meters read "0.022 / 2.1 cores",
"1.8 GB / 2.1 GB"; the detail page's four share cards carry the same figures, and its limit and request
charts read as cores or bytes. The summary band reads the same metric set as the list.

Workloads (`listWorkloadsQuery`, `workloadDetailSummaryQuery`): the same per-sample divisor, given only when
every pod of the workload ran under one limit. The list's peak meters and the detail cards and charts then
carry cores and bytes; workloads whose pods run under different limits keep the percent alone.

Nodes: the utilization charts read as cores and bytes of allocatable (the cards already carried them).

Containers (`listContainersQuery`, `containerCountersSummaryQuery`): memory reads usage of the limit from
the docker_stats `container.memory.usage.total` / `.limit` sums, filtered by the list's own filters (an
image filter keeps a reused name's old image out) and left-joined per (name, host); their ratio equals
`container.memory.percent`. A limit that changed within the window gives no figure. Docker's CPU percent is
not a share of a core count, so CPU has no figure.

Supabase: the memory and disk cells, the degraded reason and the overview finding carry bytes of the
project's memory and disk size.

Figures beside a share of a limit or request are share × divisor (`formatShareOfLimit`), so they always read
as the percent beside them; usage stands alone only where there is no limit. A pod name reused across two
clusters folds both into one row, and a usage peak from one beside a share from the other no longer disagrees.

Charts: `InfraMetric` specs take an optional `absolute` (`{ unit, totals }` by series, `*` for all), and
`formatSeriesValue` adds the figure in legends and tooltips; the axis stays in percent.

Compatibility: every new response field is a `Schema.optionalKey` (0 or absent = not sent), so a web build
with them still decodes an older API's response and shows percents only. A missing metric never renders an
invented "0 cores" / "0 B".

Layout (Effect UI pages): `MeterRows` takes an optional `detail` per row in a fixed 112 px lane;
`figureLane: true` keeps the lane for a row with no figure, so a table draws every bar at one length and every
percent in one column. The host, pod and container tables key their lanes on the page column
(`@container/page`) instead of the viewport, since the sidebar narrows it; the lanes live in one place
(`FLEET_LANES`, `InfraCells.ts`). Below 800 px of page the meters read under the name. Narrow single-meter
cells (nodes, workload peaks) put the figure under the meter instead (`CaptionedMeter`), so no column widens.

Tests: query-engine infra/containers suites (per-sample divisors, same-reading disk bytes, container byte
filters, filesystem totals), `formatSeriesValue`, the figure formatters and `podAbsolute`, the Supabase degraded
reasons, the host findings, the regenerated SQL baseline, and the infra pages' parity baselines (regenerated:
every change adds the figure lane and its text; the cost page's parity failures are upstream's own).
Live-checked on a 78-pod / 20-host / 18-container fleet: every figure ÷ its divisor equals the percent beside
it.
…or pod

The memory total and the pod limits were paired per scrape, so the group
grew with hosts or pods times scrapes in the window. They are now plain
per-key aggregates: total = avg used bytes / avg used share, and a limit is
usage / share at the highest sample, the lowest and the total, given only
when the three agree and every usage sample has its share. Same figures on
real data. The filesystem totals query gets its own cache id.
… series

One row per infra series, hour and retention period from metrics_sum and
metrics_gauge, with the resource and point attributes cut to the keys the
infra pages read. The per-core cpu attribute is dropped, so a host's CPU
states fold into one row. Rows carry sum, count, max, min, positive-only
stats, first and last seen, and earliest, latest and peak-time states,
enough for every aggregate the infra list and detail queries take.

RetentionDays is copied from the raw points and partitions the table like
the raw tables do, so an hour of a short-period source expires with its
points. Migration 0078 backfills 90 days before the views exist; Tinybird
replays history on the first deploy (not in SKIP_BACKFILL). Local schema
v70.
@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@maple-review-bot

This comment has been minimized.

@maple-review-bot

This comment has been minimized.

The container summary reads it beside the memory and restart counters the
rollup already keeps.
@maple-review-bot

This comment has been minimized.

@Makisuo

Makisuo commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

F1 fixed in 49f9878. container.pids.count is now in INFRA_CONTAINER_METRICS, and the frozen copies (migration 0078 and the local v70 step), the generated schema and the manifest are regenerated. I also compared every metric the infra and container queries read against the list. The only other one missing is system.network.io, a counter used only by the host network chart, which this rollup does not serve.

On the checklist:

  • Migration: 0078 is requiredForIngest: false, creates a new table and views only, and changes nothing existing. The code deployed now never reads the table.
  • Order: this PR is the schema only. The reads come in perf(infra): read hosts, pods and workloads from infra_metrics_hourly #3275, which stacks on it, so the table is deployed first. Those reads also fall back to raw points when the table is missing.
  • First-deploy CPU: both the replay and the 0078 backfill scan the metric tables, like the aws_metrics_hourly deploy did. Matching rows per day: 16.3M on US and 2.0M on EU, against 2.2M and 14.5M for aws.*. CPU should be watched on that deploy.

…streak test (#3271)

Assigning undefined back to process.exitCode is a no-op in Bun, so the 78
a chDB refusal sets leaked out whenever this file ran before any other set
the exit code: the CLI suite failed with every test passing.
@maple-review-bot

This comment has been minimized.

@maple-review-bot

maple-review-bot Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Maple review

🟡 Confidence 6/10 · needs attention. Held at 6 because 29 reviewed files were not read.
no findings · tests partial −1 · risk medium · 29 files not read

Adds the infra_metrics_hourly rollup (two views, migration 0078, local schema v70, catalog and scoped-delete wiring) and routes the infra pages and chart kit through it. Schema, frozen SQL copies and read queries agree. Not read: the __parity__ HTML snapshots and four fixture-data files with no inlineable patch.

  • New infra_metrics_hourly AggregatingMergeTree keeps one row per infra series and hour, filled by sum and gauge views
  • Infra list and detail reads move from raw metrics_gauge/metrics_sum points to the hourly rollup
  • Migration 0078 backfills 90 days in day chunks; local schema v70 rebuilds it from retained points
  • Host, pod, workload and container views show cores and bytes beside their percents

Before merge

Files not reviewed (29)

The review ended before it read these diffs, so nothing above vouches for them.

  • apps/web/src/native/pages/infra-integrations/supabase-list/__parity__/custom-range.html
  • apps/web/src/native/pages/infra-integrations/supabase-list/__parity__/loaded.html
  • apps/web/src/native/pages/infra-integrations/supabase-list/__parity__/loading.html
  • apps/web/src/native/pages/infra-integrations/supabase-list/__parity__/no-logs.html
  • apps/web/src/native/pages/infra-integrations/supabase-list/__parity__/orphaned.html
  • apps/web/src/native/pages/infra-integrations/supabase-list/__parity__/panels-failed.html
  • apps/web/src/native/pages/infra-integrations/supabase-list/__parity__/panels-loading.html
  • apps/web/src/native/pages/infra-integrations/supabase-list/__parity__/projects-loading.html
  • apps/web/src/native/pages/infra-integrations/supabase-list/__parity__/quiet.html
  • apps/web/src/native/pages/infra-integrations/supabase-list/__parity__/revoked.html
  • apps/web/src/native/pages/infra/container-detail/__parity__/host-scoped.html
  • apps/web/src/native/pages/infra/container-detail/__parity__/loaded.html
  • apps/web/src/native/pages/infra/container-detail/__parity__/series-failed.html
  • apps/web/src/native/pages/infra/container-detail/__parity__/series-loading.html
  • apps/web/src/native/pages/infra/containers-list/__parity__/facets-failed.html
  • apps/web/src/native/pages/infra/host-detail/__parity__/error.html
  • apps/web/src/native/pages/infra/service-lens/__parity__/custom-range.html
  • apps/web/src/native/pages/infra/service-lens/__parity__/loaded.html
  • apps/web/src/native/pages/infra/service-lens/__parity__/loading.html
  • apps/web/src/native/pages/infra/service-lens/__parity__/one-node.html
  • apps/web/src/native/pages/infra/service-lens/__parity__/rail-failed.html
  • apps/web/src/native/pages/infra/service-lens/__parity__/top-of-many.html
  • apps/web/src/native/pages/infra/workload-detail/WorkloadDetailPage.ts
  • apps/web/src/native/pages/infra/workload-detail/__parity__/custom-range.html
  • apps/web/src/native/pages/infra/workload-detail/__parity__/loaded.html
  • apps/web/src/native/pages/infra/workload-detail/__parity__/loading.html
  • apps/web/src/native/pages/infra/workload-detail/__parity__/no-cpu-usage.html
  • apps/web/src/native/pages/infra/workload-detail/__parity__/no-namespace.html
  • apps/web/src/native/pages/infra/workload-detail/__parity__/pods-failed.html

69b53a7 · What was checked, coverage and telemetry details are on the Maple / review check. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

Base automatically changed from review/pr-3239-fixes to main December 4, 2026 23:40
@Makisuo
Makisuo merged commit 53b4a8d into main Dec 4, 2026
56 of 70 checks passed
@Makisuo
Makisuo deleted the infra-rollup/table branch December 4, 2026 23:41
@maple-review-bot

Copy link
Copy Markdown

Merged with 2 steps from "Before merge" still open. If they are done, tick them on the review comment; if not, now is the time.

  • Migration · Check it is safe on production data and with the code still deployed
  • Warehouse · Deploy the schema before the code that reads it

@maple-review-bot

Copy link
Copy Markdown

Merged with 1 step from "Before merge" still open. If it is done, tick it on the review comment; if not, now is the time.

  • Manual · Expect the first Tinybird deploy to replay the rollup's history; the author measured 16.3M US / 2.0M EU rows written

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants