Rank VMs by allocated storage, and unbreak the VM metrics - #663
Open
traviswu-bigstack wants to merge 1 commit into
Open
traviswu-bigstack wants to merge 1 commit into
traviswu-bigstack wants to merge 1 commit into
Conversation
This was referenced Sep 15, 2026
traviswu-bigstack
force-pushed
the
travis.wu/vm-storage-usage-rank
branch
from
September 15, 2026 03:40
dd43bca to
c6fc668
Compare
Adds storageUsage to the VM metric types: per-VM disk usage as a percentage, ranked high to low, backing the "Disk Usage" option on the VM ranking panel. A percentage, in the same units as the cpuUsage and memoryUsage options it sits beside on that card. The figure is the guest filesystem reading -- used over total across the instance's mounted filesystems -- not blocks allocated in the pool. The two diverge by large factors and the block number is the wrong one to call usage: Ceph keeps a block allocated once written unless the guest passes TRIM through, so on one measured instance the pool reported 85% while the guest reported 14.8%, and an fstrim that freed 32.1 GiB inside the guest moved the pool figure by nothing. An instance whose qemu-guest-agent does not answer therefore has no reading and does not appear in the ranking, rather than ranking as zero. Absent means not measured. Named storageUsage rather than diskUsage because diskUsage is already taken by the host filesystem percentage -- a different entity. Fixes the six VM statements that still read from the monasca bucket. #1457 retired monasca and moved those series to telegraf, so every VM rank and every VM history -- cpu, memory, read/write iops, network in/out -- returned empty against a database nothing writes to any more. The VM Ranking card on the dashboard was blank for all of them, not only for the new metric. All six measurements were confirmed to be receiving writes in telegraf before the switch. Byte counters come back from influx as int64, not float64. The float64 type assertion silently yielded 0, so ranked values rendered as zero; the history parser would have dropped every point. Both now go through one reader that accepts either. The rank points always carry a history slice, never nil. The dashboard maps over it directly, so a nil crashed the page with "Cannot read properties of null (reading 'map')" the moment the new metric was selected. isMetricTypeValid is a second, hardcoded allowlist beside the OpenAPI enum; a type absent from it is rejected with 400 however well the spec describes it. Submodule bumped for the enum (cube-cos-openapi#115). Signed-off-by: Travis Wu <travis.wu@bigstack.co>
traviswu-bigstack
force-pushed
the
travis.wu/vm-storage-usage-rank
branch
from
September 16, 2026 06:19
c6fc668 to
a27e64b
Compare
traviswu-bigstack
marked this pull request as ready for review
September 16, 2026 06:23
traviswu-bigstack
requested review from
a team and
raven-pan
as code owners
September 16, 2026 06:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind feature
/kind bug
Which issue(s) this PR fixes?
Part of bigstack-oss/cubecos#1449 (collector: bigstack-oss/cubecos#1450, spec: bigstack-oss/cube-cos-openapi#115).
What this PR does?
Feature — adds
storageUsageto the VM metric types: per-VM disk usage as a percentage, ranked high to low, backing the "Disk Usage" option on the VM ranking panel. Same units as thecpuUsageandmemoryUsageoptions it sits beside on that card.The figure is the guest filesystem reading — used over total across the instance's mounted filesystems — not blocks allocated in the pool. The two diverge by large factors, and the block number is the wrong one to call usage: Ceph keeps a block allocated once written unless the guest passes TRIM through. On a measured instance here the pool reported 85% while the guest reported 14.8%, and an
fstrimthat freed 32.1 GiB inside the guest moved the pool figure by nothing.An instance whose qemu-guest-agent does not answer therefore has no reading and does not appear in the ranking, rather than ranking as zero — absent means not measured.
Named
storageUsagerather thandiskUsagebecausediskUsageis already the host filesystem percentage.Bug — all VM metrics were reading a dead database. Six statements still queried
Bucket("monasca"). #1457 retired monasca and moved those series totelegraf, so every VM rank and every VM history — cpu, memory, read/write iops, network in/out — returned empty. The VM Ranking card was blank for all of them, not just the new metric. I confirmed all six measurements are actively written intelegraf(80–290 points per 10 min) before switching the bucket.Bug — ranked values all rendered as 0. Byte counters come back from influx as
int64; thefloat64type assertion silently yielded 0. Both the rank and history parsers now go through one reader that accepts either.Bug — selecting the new metric crashed the dashboard with
TypeError: Cannot read properties of null (reading 'map'). The rank points now always carry a history slice, never nil.Bug —
isMetricTypeValidis a second hardcoded allowlist beside the OpenAPI enum, so a type missing from it is rejected with 400 no matter what the spec says.Test results (optional)
1). API docs updated — enum in the submodule (bigstack-oss/cube-cos-openapi#115);
api/docs.jsonis gitignored and generated at build time.go vet ./internal/...andgo build ./cmdclean.Verified against a live single-node cluster. Before, every VM rank type answered with an empty list; after:
storageUsagevalues match what the guest reports (dfinsidelrubuntu: 5.7 G of 38 G = 15%), rank points carry a populatedhistory, and the ranking card renders percentages beside the CPU card's%where it previously threw.