Skip to content

feat(allocation): custom label aggregation in home + report dropdowns#274

Open
tormodmacleod wants to merge 2 commits into
opencost:mainfrom
tormodmacleod:feat/allocation-label-aggregation
Open

feat(allocation): custom label aggregation in home + report dropdowns#274
tormodmacleod wants to merge 2 commits into
opencost:mainfrom
tormodmacleod:feat/allocation-label-aggregation

Conversation

@tormodmacleod

Copy link
Copy Markdown
Contributor

What does this PR change?

  • Replaces the home-page Cost Allocation "Aggregate by" Select with a Carbon ComboBox that accepts either a preset workload type or a free-text label key. Bare keys are auto-prefixed with label: before being passed to /allocation/compute, which already supports aggregate=label:<key>.
  • Mirrors the same pattern on the Report Builder side panel's per-row Groupings selector so custom label keys can be aggregated in reports too. Values flow through the existing comma-joined groupingsaggregate= path.
  • Adds label:app.kubernetes.io/name as a built-in example on both surfaces so users discover the format without needing documentation — the Kubernetes recommended label is set by Helm on virtually all charts and is present in the vast majority of clusters.
  • Wraps the reports ComboBox in <Theme theme="white"> so it renders light regardless of the user's OS/app theme, matching the side panel's hard-coded light Tailwind styling.

Does this PR relate to any other PRs?

  • None.

How will this PR impact users?

  • Users can aggregate cost data by any Kubernetes label without leaving the UI. Previously the workload-type Select was the only option, and aggregating by label required hand-editing the URL or hitting the API directly.
  • Discoverability: label:app.kubernetes.io/name is now visible as a preset, hinting at the label:<key> format for users who don't know it.
  • No backwards-incompatible changes to existing presets — typed values that match a preset (namespace, deployment, etc.) behave exactly as before.

Does this PR address any GitHub or Zendesk issues?

How was this PR tested?

  • Manual: in a dev build pointed at a real cluster, selected the new label:app.kubernetes.io/name preset on both the home page and the Report Builder and confirmed /allocation/compute was called with aggregate=label:app.kubernetes.io/name and the chart/table rendered the expected aggregation.
  • Manual: typed bare keys (e.g. version) and verified they submitted as label:version; typed prefixed values (e.g. annotation:foo) and verified they passed through unchanged.
  • Manual: verified the Groupings ComboBox renders with light styling whether the app is in cds--white or cds--g100 theme.
  • npm run typecheck — no new type errors introduced (the 57 pre-existing legacy errors are unchanged).

Does this PR require changes to documentation?

  • No. The label:<key> form is already supported by /allocation/compute; this PR only surfaces it in the UI. The preset itself serves as inline documentation of the format.

Have you labeled this PR and its corresponding Issue as "next release" if it should be part of the next OpenCost release? If not, why not?

  • Yes — small, additive, low-risk UI change. Targeting the next release.

@netlify

netlify Bot commented Jun 16, 2026

Copy link
Copy Markdown

Deploy Preview for opencost-ui ready!

Name Link
🔨 Latest commit af4ef7d
🔍 Latest deploy log https://app.netlify.com/projects/opencost-ui/deploys/6a3148e9adda8800084558a7
😎 Deploy Preview https://deploy-preview-274--opencost-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

tormodmacleod and others added 2 commits June 16, 2026 13:57
Replace the Aggregate-by Select with a Carbon ComboBox that accepts
either a preset workload type or a free-text label key. Bare keys typed
by the user are auto-prefixed with `label:` before being passed to the
existing /allocation/compute API, which already supports
`aggregate=label:<key>`.

Add `label:app.kubernetes.io/name` as a built-in example so users
discover the format without needing documentation; the Kubernetes
recommended label is set by Helm on virtually all charts and is
present in the vast majority of clusters.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Tormod Macleod <tormod.macleod@gmail.com>
Mirror the home-page Aggregate-by ComboBox (commit f656a97) on the
Report Builder side panel. The per-row Groupings selector is replaced
with a Carbon ComboBox that accepts either a preset workload type or a
free-text label key. Bare keys are auto-prefixed with `label:` before
being passed to the existing /allocation/compute API, which already
supports `aggregate=label:<key>` in the comma-joined groupings list.

Add `label:app.kubernetes.io/name` as a built-in example so users
discover the format without needing documentation.

The ComboBox is wrapped in `<Theme theme="white">` to match the side
panel's hard-coded light styling — otherwise it would inherit the
page-level Carbon theme and render dark while the surrounding panel
stays light.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Tormod Macleod <tormod.macleod@gmail.com>
@tormodmacleod tormodmacleod force-pushed the feat/allocation-label-aggregation branch from 32689eb to af4ef7d Compare June 16, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant