Skip to content

HDDS-15333. Expose volume and bucket utilization metrics on OM /prom#10576

Open
prathmesh12-coder wants to merge 2 commits into
apache:masterfrom
prathmesh12-coder:HDDS-15333
Open

HDDS-15333. Expose volume and bucket utilization metrics on OM /prom#10576
prathmesh12-coder wants to merge 2 commits into
apache:masterfrom
prathmesh12-coder:HDDS-15333

Conversation

@prathmesh12-coder

Copy link
Copy Markdown

What changes were proposed in this pull request?

This PR includes OM Prometheus metrics on /prom with volume-level utilization gauges and adds a missing bucket namespace usage gauge.

OM already exposes bucket utilization metrics (bucket_utilization_metrics_*) on /prom, but volume-level used/available byte metrics were not exposed.

Requested improvement:
-> Expose OM Prometheus metrics for below.

  • volume used bytes
  • volume quota bytes
  • volume available bytes, if applicable
  • volume namespace quota
  • volume used namespace
  • bucket used namespace


-> This would allow operators to build Grafana dashboards and alerts for both volume and bucket quota usage without relying on custom exporters or CLI polling.

Changes made:

  1. Added VolumeUtilizationMetrics — a new MetricsSource registered on OM that publishes, per volume:

    • VolumeQuotaBytes — byte quota (-1 if unlimited)
    • VolumeUsedBytes — sum of usedBytes across all buckets in the volume
    • VolumeAvailableBytes — quota - used when a byte quota is set, otherwise -1
    • VolumeQuotaNamespace — existing namespace quota
    • VolumeUsedNamespace — existing namespace usage

  2. Added OMMetadataManager.getVolumeIterator() — mirrors the existing getBucketIterator() API so volume metrics can iterate OM metadata.


  3. Extended BucketUtilizationMetrics — exposed BucketUsedNamespace (number of keys/directories in the bucket), which was previously missing from /prom. 


  4. On /prom, these appear as volume_utilization_metrics_* and bucket_utilization_metrics_bucket_used_namespace, following the same normalization as existing bucket utilization metrics.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-15333

How was this patch tested?

  • Unit tests

    • TestVolumeUtilizationMetrics — verifies volume quota, used bytes, available bytes, and namespace gauges.
    • TestBucketUtilizationMetrics — updated to cover BucketUsedNamespace.

  • Manual testing (docker compose cluster)

    • Verified metrics on OM /prom:

    curl -s http://localhost:9874/prom | grep volume_utilization_metrics

    curl -s http://localhost:9874/prom | grep bucket_utilization_metrics_bucket_used_namespace
    
    • Confirmed volume_utilization_metrics_volume_used_bytes increases after writes and volume_utilization_metrics_volume_available_bytes reflects quota minus usage.

  • CI — GitHub Actions build-branch succeeded on fork (HDDS-15333): https://github.com/prathmesh12-coder/ozone/actions/runs/27940909061

Added VolumeUtilizationMetrics with volume used/available bytes,
register them on OM, and expose bucket used namespace.
@errose28

Copy link
Copy Markdown
Contributor

@rnblough You may be interested in this as well.

Comment on lines +79 to +88
Map<String, Long> usedBytesPerVolume = new HashMap<>();
Iterator<Entry<CacheKey<String>, CacheValue<OmBucketInfo>>> bucketIterator = metadataManager.getBucketIterator();
while (bucketIterator.hasNext()) {
Entry<CacheKey<String>, CacheValue<OmBucketInfo>> entry = bucketIterator.next();
OmBucketInfo bucketInfo = entry.getValue().getCacheValue();
if (bucketInfo == null) {
continue;
}
usedBytesPerVolume.merge(bucketInfo.getVolumeName(), bucketInfo.getUsedBytes(), Long::sum);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding these metrics. Overall these look like good additions, I just have a concern with the volume used bytes. It is not directly tracked by Ozone because volumes don't have any connection to files, only buckets. Hence the used namespace tracked per volume is just a count of number of buckets and there is no used bytes for volumes.

I think this could be aggregated with promQL outside of Ozone if needed.

cc @sumitagrawl

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @errose28, Thanks for the feedback!
Removed the VolumeUsedBytes and VolumeAvailableBytes metrics along with the aggregation logic.

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