Skip to content

Strip shared pod-name prefix from metric chart legends#189

Merged
acoshift merged 3 commits into
mainfrom
hide-pod-prefix
Jun 11, 2026
Merged

Strip shared pod-name prefix from metric chart legends#189
acoshift merged 3 commits into
mainfrom
hide-pod-prefix

Conversation

@acoshift

Copy link
Copy Markdown
Member

What

Deployment/disk metric charts label each per-pod line by its full k8s pod name<resourceName>-<projectID>-<rsHash>-<podHash>. Every pod of one deployment shares that long prefix, so the legend repeats it on every entry and the only part that actually distinguishes one pod from another — the trailing pod hash — gets pushed off the edge. With the new id-based deployment naming (deploy-by-id), that shared prefix is also an opaque 0d<id> resource name the user never chose.

This strips the shared prefix and shows only the distinguishing suffix:

Usage · 0d128-77-7d8f9b6c5-x2k9pUsage · x2k9p

How

Chart.svelte computes the longest prefix common to all lines in a panel, trimmed back to a - boundary so only whole name segments are removed (never a hash cut mid-token), then renders name.slice(prefixLen).

  • Safe by construction: when the lines share no --bounded prefix, the helper returns 0 and labels are byte-identical to today. Project-level usage charts (single-line series) and aggregate mode (one line per series, named by deployment) are therefore unaffected — podLabel is only reached for multi-line series.
  • Verified against the backend: in non-aggregate deployment.metrics, every line (usage and limit/allocated) is keyed by the pod label, so the common-prefix strip applies uniformly across a panel. In aggregate mode each series is a single deployment-named line, so the label path isn't taken.

Also makes the mock deployment.metrics fixture faithful to live (non-aggregate) mode — two pods of an id-named deployment, every line keyed by full pod name — which is what exercises the new behavior offline.

Verification

bun lint ✅ · bun check ✅ (0 errors) · rendered in mock mode, light + dark.

Legend before: Usage · 0d128-77-7d8f9b6c5-x2k9p, Usage · 0d128-77-7d8f9b6c5-q8m2t, …
Legend after: Usage · x2k9p, Usage · q8m2t, Limit · x2k9p, Limit · q8m2t, …

🤖 Generated with Claude Code

Per-pod metric lines are keyed by the full k8s pod name
(`<resourceName>-<projectID>-<rsHash>-<podHash>`). That prefix is
identical on every pod of a deployment, so in the legend it's pure noise
that pushes the only distinguishing part — the pod hash — off the edge.
With id-based deployment naming the prefix is also an opaque `0d<id>`
resource name the user never chose.

Chart.svelte now computes the longest prefix common to every line in a
panel, trimmed back to a '-' boundary so whole name segments are removed
(never a hash mid-token), and shows only the remaining suffix
("Usage · x2k9p"). When lines share no '-'-bounded prefix the function
returns 0 and labels are unchanged, so non-pod charts (project usage,
aggregate mode) are unaffected.

Also makes the mock `deployment.metrics` fixture faithful to live
(non-aggregate) mode: two pods of an id-named deployment, every line
keyed by full pod name — which is what exercises the new stripping.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 11, 2026

Copy link
Copy Markdown

Deploying deploys-app--console with  Cloudflare Pages  Cloudflare Pages

Latest commit: 09183c3
Status: ✅  Deploy successful!
Preview URL: https://8a2673cf.deploys-app--console.pages.dev
Branch Preview URL: https://hide-pod-prefix.deploys-app--console.pages.dev

View logs

acoshift and others added 2 commits June 11, 2026 19:17
Extends the metrics-legend prefix stripping to the deployment logs and
events pages. Pod names there are the full k8s name
(`<kubeName>-<projectID>-<rsHash>-<podHash>`) — the logs chip shows it
verbatim, and event messages embed it in free text. The shared
`<kubeName>-<projectID>` part is noise (and, for id-named deployments,
the opaque `0d<id>`).

New `$lib/deployment/podName.js` derives the prefix from the deployment's
`internalAddress` (which the API sets to exactly `<kubeName>-<projectID>`)
and strips it wherever it appears, with a `0d<id>-<projectID>` fallback
so id-named pods are hidden even if internalAddress is unavailable.

- logs: chip shows the `<rsHash>-<podHash>` suffix; full name kept for the
  hash color and the hover title.
- events: pod refs in reason/message are stripped; full text kept on hover.
  Container names and namespaces are left intact.

Mocks made faithful so this is exercisable offline: deployment
internalAddress is now the real `<kubeName>-<projectID>` format, and the
mock log/event feeds use full id-named pod names.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The apiserver resource-name prefix changed from `0d<id>` to `d<id>` so the
derived k8s Service name is a valid DNS-1035 label. Update the pod-name
stripper's fallback regex (`0d\d+-\d+` → `d\d+-\d+`) and the mock pod
names/internalAddress to match. The primary strip path (exact
internalAddress) is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@acoshift acoshift merged commit 78c45c8 into main Jun 11, 2026
5 checks passed
@acoshift acoshift deleted the hide-pod-prefix branch June 11, 2026 13:07
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.

1 participant