Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added metrics bucket_object_count, bucket_max_objects_quota and bucke…
…t_max_size_quota for quota

Signed-off-by: Aayush Chouhan <[email protected]>
  • Loading branch information
aayushchouhan09 committed Sep 16, 2025
commit 0e4f273ee972ff314e07fd458b17e41a9e2634aa
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,27 @@ const NOOBAA_CORE_METRICS = js_utils.deep_freeze([{
help: 'Bucket Quantity Quota Precent',
labelNames: ['bucket_name']
}
}, {
type: 'Gauge',
name: 'bucket_object_count',
configuration: {
help: 'Current Number of Objects per Bucket',
labelNames: ['bucket_name']
}
}, {
type: 'Gauge',
name: 'bucket_max_objects_quota',
configuration: {
help: 'Bucket Maximum Objects Quota',
labelNames: ['bucket_name']
}
}, {
type: 'Gauge',
name: 'bucket_max_bytes_quota',
configuration: {
help: 'Bucket Maximum Bytes Quota',
labelNames: ['bucket_name']
}
}, {
type: 'Gauge',
name: 'resource_status',
Expand Down Expand Up @@ -563,6 +584,9 @@ class NooBaaCoreReport extends BasePrometheusReport {
this._metrics.bucket_capacity.reset();
this._metrics.bucket_tagging.reset();
this._metrics.bucket_used_bytes.reset();
this._metrics.bucket_object_count.reset();
this._metrics.bucket_max_objects_quota.reset();
this._metrics.bucket_max_bytes_quota.reset();
buckets_info.forEach(bucket_info => {
const bucket_labels = { bucket_name: bucket_info.bucket_name };
if (bucket_info.tagging && bucket_info.tagging.length) {
Expand All @@ -574,6 +598,9 @@ class NooBaaCoreReport extends BasePrometheusReport {
this._metrics.bucket_quantity_quota.set({ bucket_name: bucket_info.bucket_name }, bucket_info.quota_quantity_percent);
this._metrics.bucket_capacity.set({ bucket_name: bucket_info.bucket_name }, bucket_info.capacity_precent);
this._metrics.bucket_used_bytes.set({ bucket_name: bucket_info.bucket_name }, bucket_info.bucket_used_bytes);
this._metrics.bucket_object_count.set({ bucket_name: bucket_info.bucket_name }, bucket_info.object_count || 0);
this._metrics.bucket_max_objects_quota.set({ bucket_name: bucket_info.bucket_name }, bucket_info.quota_max_objects || 0);
this._metrics.bucket_max_bytes_quota.set({ bucket_name: bucket_info.bucket_name }, bucket_info.quota_max_bytes || 0);
});
}

Expand Down
21 changes: 19 additions & 2 deletions src/server/system_services/stats_aggregator.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,19 @@ async function get_partial_systems_stats(req) {
}
}

function _get_bucket_quota_info(bucket) {
const quota = new Quota(bucket.quota);
const { size_used_percent, quantity_used_percent } = quota.get_bucket_quota_usages_percent(bucket);
const quota_max_objects = quota.get_quota_by_quantity() === '0' ? 0 : parseInt(quota.get_quota_by_quantity(), 10);
const quota_max_bytes = quota.get_quota_by_size() === '0' ? 0 : size_utils.json_to_bigint(quota.get_quota_by_size()).toJSNumber();

return {
size_used_percent,
quantity_used_percent,
quota_max_objects,
quota_max_bytes
};
}

async function _partial_buckets_info(req) {
const buckets_stats = _.cloneDeep(PARTIAL_BUCKETS_STATS_DEFAULTS);
Expand Down Expand Up @@ -515,7 +528,8 @@ async function _partial_buckets_info(req) {
const bucket_available = size_utils.json_to_bigint(_.get(bucket_info, 'data.free') || 0);
const bucket_total = bucket_used.plus(bucket_available);
const is_capacity_relevant = _.includes(CAPACITY_MODES, bucket_info.mode);
const { size_used_percent, quantity_used_percent } = new Quota(bucket.quota).get_bucket_quota_usages_percent(bucket);
const { size_used_percent, quantity_used_percent, quota_max_objects, quota_max_bytes } = _get_bucket_quota_info(bucket);

buckets_stats.buckets.push({
bucket_name: bucket_info.name.unwrap(),
quota_size_precent: size_used_percent,
Expand All @@ -524,7 +538,10 @@ async function _partial_buckets_info(req) {
.divide(bucket_total)) : 0,
is_healthy: _.includes(OPTIMAL_MODES, bucket_info.mode),
tagging: bucket_info.tagging || [],
bucket_used_bytes: bucket_used.valueOf()
bucket_used_bytes: bucket_used.valueOf(),
object_count: bucket_info.num_objects.value || 0,
quota_max_objects: quota_max_objects,
quota_max_bytes: quota_max_bytes
});
}

Expand Down