Skip to content

fix: expose Nova capacity metrics in bytes - #160

Open
Jeremy Lee (legit-ninja) wants to merge 1 commit into
vexxhost:mainfrom
samaritanark:contrib/nova-bytes-2b2
Open

Jeremy Lee (legit-ninja) wants to merge 1 commit into
vexxhost:mainfrom
samaritanark:contrib/nova-bytes-2b2

Conversation

@legit-ninja

@legit-ninja Jeremy Lee (legit-ninja) commented Dec 1, 2026 •

Copy link
Copy Markdown

Summary

Convert four Nova capacity metrics from MiB/GiB to bytes, following the Prometheus guidance to use base units with explicit unit suffixes, and the exporter guidelines.

Old metric New metric Conversion
openstack_nova_quota_ram openstack_nova_quota_ram_bytes MiB × 2^20
openstack_nova_limits_memory_max openstack_nova_limits_memory_max_bytes MiB × 2^20
openstack_nova_limits_memory_used openstack_nova_limits_memory_used_bytes MiB × 2^20
openstack_nova_server_local_gb openstack_nova_server_local_bytes GiB × 2^30

Behavior

  • -1 (unlimited) is preserved for quota and memory limits only. Zero stays zero; signed usage, including negative values, is scaled.
  • Values are converted to float64 before multiplying, so there is no integer overflow; float64 precision applies.
  • Labels, quota calculation, defaults and scrape failure behavior are unchanged. RAM usage still comes from Placement, and quota reservations remain zero.
  • server_local_bytes still measures only instances.root_gb; it excludes ephemeral disk, swap and actual disk use.
  • Status, task-state, CPU, count and health metrics are unchanged.

Breaking metric changes

The four old metric families are removed without aliases. Update PromQL queries, dashboards, alerts, recording rules and allowlists to the new names, remove any MiB/GiB-to-byte multipliers, and express thresholds in bytes. Filter unlimited limits before arithmetic, for example openstack_nova_quota_ram_bytes{type="limit"} >= 0. Queries spanning the rollout need to handle the old series separately. The README documents the migration.

Scope

Nova is converted first because these changes are self-contained and need no new database APIs. The Cinder and Manila capacity metrics move to bytes in #162 and #163, alongside their quota changes, so the exporter is mixed-unit only until those merge.

#117 also changes Nova accounting and labels but not these conversions. This PR keeps the current upstream labels; if both are accepted, the later one needs to reconcile the label contracts.

Tests

Unit tests for the unit conversions (including -1, zero and negative usage) and inventory capacity, plus updated end-to-end metric expectations. No openstackdb changes are needed.

## Summary

Convert four Nova capacity metrics from MiB/GiB to bytes, following the Prometheus guidance to use [base units](https://prometheus.io/docs/practices/naming/#base-units) with explicit unit suffixes, and the [exporter guidelines](https://prometheus.io/docs/instrumenting/writing_exporters/#naming).

Old metric New metric Conversion
openstack_nova_quota_ram openstack_nova_quota_ram_bytes MiB × 2^20
openstack_nova_limits_memory_max openstack_nova_limits_memory_max_bytes MiB × 2^20
openstack_nova_limits_memory_used openstack_nova_limits_memory_used_bytes MiB × 2^20
openstack_nova_server_local_gb openstack_nova_server_local_bytes GiB × 2^30

Behavior

  • -1 (unlimited) is preserved for quota and memory limits only. Zero stays zero; signed usage, including negative values, is scaled.
  • Values are converted to float64 before multiplying, so there is no integer overflow; float64 precision applies.
  • Labels, quota calculation, defaults and scrape failure behavior are unchanged. RAM usage still comes from Placement, and quota reservations remain zero.
  • server_local_bytes still measures only instances.root_gb; it excludes ephemeral disk, swap and actual disk use.
  • Status, task-state, CPU, count and health metrics are unchanged.

Breaking metric changes

The four old metric families are removed without aliases. Update PromQL queries, dashboards, alerts, recording rules and allowlists to the new names, remove any MiB/GiB-to-byte multipliers, and express thresholds in bytes. Filter unlimited limits before arithmetic, for example openstack_nova_quota_ram_bytes{type="limit"} >= 0. Queries spanning the rollout need to handle the old series separately. The README documents the migration.

Scope

Nova is converted first because these changes are self-contained and need no new database APIs. The Cinder and Manila capacity metrics move to bytes in #162 and #163, alongside their quota changes, so the exporter is mixed-unit only until those merge.

[#117](#117) also changes Nova accounting and labels but not these conversions. This PR keeps the current upstream labels; if both are accepted, the later one needs to reconcile the label contracts.

Tests

Unit tests for the unit conversions (including -1, zero and negative usage) and inventory capacity, plus updated end-to-end metric expectations. No openstackdb changes are needed.

Convert RAM quota and memory limits from MiB, and server root disk capacity from GiB, while preserving labels, unlimited limits and signed usage. Add capacity regression coverage and document the breaking metric migration.

Signed-off-by: David Hulick <dave.hulick@gmail.com>
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