---
id: w3/m4.5/t001
title: "Application Metrics history charts: Memory/CPU/Total Instances draw stepped series"
worker: worker3
status: done
estimate: 45m
depends_on: []
---

## Objective

Replace the three stat-only Application Metrics cards with real history charts — the same chart components the Network Metrics cards use — fed by the multi-point stepped series w3/m4's backend already returns (verified live: 61 points/hour per metric on prod).

## Context

- `dashboard/src/features/metrics/components/application-metrics-card.tsx` renders stat cards (built in the m3 single-point era); `network-metrics-card.tsx` + `svg-line-chart.tsx`/`svg-bar-chart.tsx` already draw multi-point series.
- `use-metrics.ts` fetches via GraphQL `metrics(query: {...})` with `start`/`end`/`resolution` — the same query now returns stepped series for `MEMORY`/`CPU`/`INSTANCES`; per-instance series carry an `instance` label (draw one line per instance, like Render).
- Keep the current headline stat as the latest point's value (Render shows the current value above the chart).
- The card caption "Per-instance resource usage, from metrics-server" is stale — the source is Prometheus (cAdvisor) with a metrics-server fallback; reword to be source-accurate.
- Percentage tab: series can be legitimately empty when pods have no limits (omit-don't-fake) — keep the existing "—"/empty handling per card.

## Steps

1. Render `MEMORY`/`CPU` as line charts (one series per `instance` label) and `INSTANCES` as a stepped line/bar, reusing the existing chart components + `chart-layout.ts`.
2. Keep the latest-value stat in the card header; wire the page's time-range/resolution state through (it already flows to the network cards).
3. Fix the caption; verify the Percentage↔Total toggle re-renders charts correctly.

## Files

- `dashboard/src/features/metrics/components/application-metrics-card.tsx`
- `dashboard/src/features/metrics/hooks/use-metrics.ts` (only if the hook shape needs points exposed)

## Acceptance criteria

- [ ] On prod `beancount-cms` (Total tab, Last hour), Memory/CPU/Total Instances each render a chart with ≥30 points, not a lone stat.
- [ ] Percentage tab still shows the honest empty state for a no-limit app.
- [ ] Caption no longer claims metrics-server as the source.

## Out of scope

- Limit labels (t002); filters (t003).
